public void RunTestsInAssembly(string pathToAssembly, string pathToConfigFile, IFrameworkHandle frameworkHandle, IEnumerable <string> specsToRun, Uri executorUri) { AppDomain appDomain = null; this.frameworkHandle = frameworkHandle; this.uri = executorUri; this.sourcePath = pathToAssembly; try { appDomain = this.CreateAppDomain(pathToAssembly, pathToConfigFile, true); IAppDomainExecutor executor = CreateAppDomainExecutor(appDomain); ISpecificationRunListener listener = new SpecificationRunListener(this.sourcePath, (Action <string>)SendErrorMessage, (Action <string, string>)RecordStart, (Action <string, string, int>)RecordEnd, (Action <string, string, DateTime, DateTime, string, string, int>)RecordResult); executor.RunTestsInAssembly(pathToAssembly, specsToRun, listener); SpecificationRunListener listenerConcrete = (SpecificationRunListener)listener; } catch (Exception) { } finally { if (appDomain != null) { string baseDirectory = appDomain.BaseDirectory; string cachePath = appDomain.SetupInformation.CachePath; AppDomain.Unload(appDomain); if (Directory.Exists(cachePath)) { Directory.Delete(cachePath, true); } string path = Path.Combine(baseDirectory, runnerDllName); if (File.Exists(path)) { File.Delete(path); } } } }
public void RunAllTestsInAssembly(string pathToAssembly, string pathToConfigFile, IFrameworkHandle frameworkHandle, Uri executorUri) { AppDomain appDomain = null; this.frameworkHandle = frameworkHandle; this.uri = executorUri; this.sourcePath = pathToAssembly; try { appDomain = this.CreateAppDomain(pathToAssembly, pathToConfigFile, true); IAppDomainExecutor executor = CreateAppDomainExecutor(appDomain); ISpecificationRunListener listener = new SpecificationRunListener(this.sourcePath, (Action<string>)SendErrorMessage, (Action<string, string>)RecordStart, (Action<string, string, int>)RecordEnd, (Action<string, string, DateTime, DateTime, string, string, int>)RecordResult); executor.RunAllTestsInAssembly(pathToAssembly, listener); SpecificationRunListener listenerConcrete = (SpecificationRunListener)listener; } catch (Exception) { } finally { if (appDomain != null) { string baseDirectory = appDomain.BaseDirectory; string cachePath = appDomain.SetupInformation.CachePath; AppDomain.Unload(appDomain); if (Directory.Exists(cachePath)) { Directory.Delete(cachePath, true); } string path = Path.Combine(baseDirectory, runnerDllName); if (File.Exists(path)) { File.Delete(path); } } } }