/// <summary> /// Execute test cases. /// </summary> /// <param name="assembly">Assembly.</param> /// <param name="testInfos">Test infos.</param> /// <param name="executionListener">Execution listener.</param> /// <remarks>It uses xunit execution engine to execute the test cases.</remarks> public void Execute(string assembly, string data, IXUnitExecutionListener executionListener) { XUnitTestInfo[] testInfos = JsonConvert.DeserializeObject <XUnitTestInfo[]> (data); var lookup = new HashSet <string> (); foreach (var testInfo in testInfos) { lookup.Add(testInfo.Id); } // we don't want to run every test in the assembly // only the tests passed in "testInfos" argument using (var controller = new XunitFrontController(AppDomainSupport.Denied, assembly, null, false, null, new NullSourceInformationProvider())) using (var discoveryVisitor = new TestDiscoveryVisitor(tc => lookup.Contains(tc.UniqueID))) using (var executionVisitor = new TestExecutionVisitor(executionListener)) { controller.Find(false, discoveryVisitor, TestFrameworkOptions.ForDiscovery()); discoveryVisitor.Finished.WaitOne(); var options = TestFrameworkOptions.ForExecution(); options.SetDisableParallelization(true); options.SetSynchronousMessageReporting(true); controller.RunTests(discoveryVisitor.TestCases, executionVisitor, options); } }
public void Execute(string assembly, XUnitTestInfo[] testInfos, IXUnitExecutionListener executionListener) { var lookup = new HashSet <string> (); foreach (var testInfo in testInfos) { lookup.Add(testInfo.Id); } // we don't want to run every test in the assembly // only the tests passed in "testInfos" argument using (var controller = new XunitFrontController(assembly, null, false)) using (var discoveryVisitor = new TestDiscoveryVisitor(tc => lookup.Contains(tc.UniqueID))) using (var executionVisitor = new TestExecutionVisitor(executionListener)) { controller.Find(false, discoveryVisitor, new TestFrameworkOptions()); discoveryVisitor.Finished.WaitOne(); controller.RunTests(discoveryVisitor.TestCases, executionVisitor, new XunitExecutionOptions { DisableParallelization = true, SynchronousMessageReporting = true }); } }