private void RunAllTests(IRunContext runContext) { ITestRunnerManager runnerManager = RuntimeAccessor.ServiceLocator.Resolve <ITestRunnerManager>(); var runner = runnerManager.CreateTestRunner(StandardTestRunnerFactoryNames.IsolatedAppDomain); runner.RegisterExtension(new RunContextExtension(runContext)); ILogger logger = new RunContextLogger(runContext); TestRunnerOptions testRunnerOptions = new TestRunnerOptions(); try { RunWithProgressMonitor(delegate(IProgressMonitor progressMonitor) { runner.Initialize(testRunnerOptions, logger, progressMonitor); }); if (isCanceled) { return; } TestPackage testPackage = new TestPackage(); testPackage.AddExcludedTestFrameworkId("MSTestAdapter.TestFramework"); foreach (ITestElement testElement in runContext.RunConfig.TestElements) { GallioTestElement gallioTestElement = testElement as GallioTestElement; if (gallioTestElement != null) { testPackage.AddFile(new FileInfo(gallioTestElement.AssemblyPath)); } } TestExplorationOptions testExplorationOptions = new TestExplorationOptions(); TestExecutionOptions testExecutionOptions = new TestExecutionOptions(); List <Filter <string> > idFilters = new List <Filter <string> >(); foreach (ITestElement includedTestElement in runContext.RunConfig.TestElements) { GallioTestElement gallioTestElement = includedTestElement as GallioTestElement; if (gallioTestElement != null) { idFilters.Add(new EqualityFilter <string>(gallioTestElement.GallioTestId)); } } testExecutionOptions.FilterSet = new FilterSet <ITestDescriptor>(new IdFilter <ITestDescriptor>(new OrFilter <string>(idFilters))); RunWithProgressMonitor(delegate(IProgressMonitor progressMonitor) { runner.Run(testPackage, testExplorationOptions, testExecutionOptions, progressMonitor); }); } finally { runner.Dispose(NullProgressMonitor.CreateInstance()); } }
/// <summary> /// Initializes a test package with the contents of this structure. /// </summary> /// <param name="testPackage">The test package to populate.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="testPackage"/> is null.</exception> public void InitializeTestPackage(TestPackage testPackage) { if (testPackage == null) { throw new ArgumentNullException("testPackage"); } GenericCollectionUtils.ForEach(files, x => testPackage.AddFile(new FileInfo(x))); GenericCollectionUtils.ForEach(hintDirectories, x => testPackage.AddHintDirectory(new DirectoryInfo(x))); GenericCollectionUtils.ForEach(excludedFrameworkIds, x => testPackage.AddExcludedTestFrameworkId(x)); testPackage.ShadowCopy = ShadowCopy; testPackage.DebuggerSetup = Debug ? new DebuggerSetup() : null; testPackage.ApplicationBaseDirectory = ApplicationBaseDirectory != null ? new DirectoryInfo(ApplicationBaseDirectory) : null; testPackage.WorkingDirectory = WorkingDirectory != null ? new DirectoryInfo(WorkingDirectory) : null; testPackage.RuntimeVersion = RuntimeVersion; GenericCollectionUtils.ForEach(Properties, x => testPackage.AddProperty(x.Key, x.Value)); }
/// <summary> /// Initializes a test package with the contents of this structure. /// </summary> /// <param name="testPackage">The test package to populate.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="testPackage"/> is null.</exception> public void InitializeTestPackage(TestPackage testPackage) { if (testPackage == null) throw new ArgumentNullException("testPackage"); GenericCollectionUtils.ForEach(files, x => testPackage.AddFile(new FileInfo(x))); GenericCollectionUtils.ForEach(hintDirectories, x => testPackage.AddHintDirectory(new DirectoryInfo(x))); GenericCollectionUtils.ForEach(excludedFrameworkIds, x => testPackage.AddExcludedTestFrameworkId(x)); testPackage.ShadowCopy = ShadowCopy; testPackage.DebuggerSetup = Debug ? new DebuggerSetup() : null; testPackage.ApplicationBaseDirectory = ApplicationBaseDirectory != null ? new DirectoryInfo(ApplicationBaseDirectory) : null; testPackage.WorkingDirectory = WorkingDirectory != null ? new DirectoryInfo(WorkingDirectory) : null; testPackage.RuntimeVersion = RuntimeVersion; GenericCollectionUtils.ForEach(Properties, x => testPackage.AddProperty(x.Key, x.Value)); }