public RunTests ( IEnumerable |
||
vsTestCasesToRun | IEnumerable |
|
runContext | IRunContext | |
frameworkHandle | IFrameworkHandle | |
return | void |
public void RunTests(IEnumerable<VsTestCase> vsTestCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
try
{
Stopwatch stopwatch = Stopwatch.StartNew();
InitOrRefreshTestEnvironment(runContext.RunSettings, frameworkHandle);
var vsTestCasesToRunAsArray = vsTestCasesToRun as VsTestCase[] ?? vsTestCasesToRun.ToArray();
ISet<string> allTraitNames = GetAllTraitNames(vsTestCasesToRunAsArray.Select(DataConversionExtensions.ToTestCase));
var filter = new TestCaseFilter(runContext, allTraitNames, _testEnvironment);
vsTestCasesToRun = filter.Filter(vsTestCasesToRunAsArray);
IEnumerable<TestCase> allTestCasesInExecutables =
GetAllTestCasesInExecutables(vsTestCasesToRun.Select(tc => tc.Source).Distinct());
ICollection<TestCase> testCasesToRun = vsTestCasesToRun.Select(DataConversionExtensions.ToTestCase).ToArray();
DoRunTests(allTestCasesInExecutables, testCasesToRun, runContext, frameworkHandle, stopwatch);
}
catch (Exception e)
{
_testEnvironment.LogError("Exception while running tests: " + e);
}
}
TestExecutor::RunTests ( IEnumerable |
public void RunTests_ParallelTestExecution_SpeedsUpTestExecution() { MockOptions.Setup(o => o.ParallelTestExecution).Returns(false); Stopwatch stopwatch = new Stopwatch(); TestExecutor executor = new TestExecutor(TestEnvironment); IEnumerable<string> testsToRun = TestResources.SampleTests.Yield(); stopwatch.Start(); executor.RunTests(testsToRun, MockRunContext.Object, MockFrameworkHandle.Object); stopwatch.Stop(); long sequentialDuration = stopwatch.ElapsedMilliseconds; MockOptions.Setup(o => o.ParallelTestExecution).Returns(true); MockOptions.Setup(o => o.MaxNrOfThreads).Returns(Environment.ProcessorCount); executor = new TestExecutor(TestEnvironment); testsToRun = TestResources.SampleTests.Yield(); stopwatch.Restart(); executor.RunTests(testsToRun, MockRunContext.Object, MockFrameworkHandle.Object); stopwatch.Stop(); long parallelDuration = stopwatch.ElapsedMilliseconds; sequentialDuration.Should().BeGreaterThan(4000); // 2 long tests, 2 seconds per test parallelDuration.Should().BeGreaterThan(2000); parallelDuration.Should().BeLessThan(4000); // 2 seconds per long test + some time for the rest }