public virtual void RunTests_WorkingDir_IsSetCorrectly() { TestCase testCase = TestDataCreator.GetTestCasesOfSampleTests("WorkingDir.IsSolutionDirectory").First(); MockOptions.Setup(o => o.WorkingDir).Returns(SettingsWrapper.ExecutableDirPlaceholder); RunAndVerifySingleTest(testCase, VsTestOutcome.Failed); MockFrameworkHandle.Reset(); MockOptions.Setup(o => o.WorkingDir).Returns(SettingsWrapper.SolutionDirPlaceholder); RunAndVerifySingleTest(testCase, VsTestOutcome.Passed); }
public virtual void RunTests_TestDirectoryViaUserParams_IsPassedViaCommandLineArg() { TestCase testCase = TestDataCreator.GetTestCasesOfSampleTests("CommandArgs.TestDirectoryIsSet").First(); RunAndVerifySingleTest(testCase, VsTestOutcome.Failed); MockFrameworkHandle.Reset(); MockOptions.Setup(o => o.AdditionalTestExecutionParam).Returns("-testdirectory=\"" + SettingsWrapper.TestDirPlaceholder + "\""); RunAndVerifySingleTest(testCase, VsTestOutcome.Passed); }
public void RunTests_CancelingExecutor_StopsTestExecution() { List <Model.TestCase> testCasesToRun = TestDataCreator.GetTestCasesOfSampleTests("Crashing.LongRunning", "LongRunningTests.Test3"); Stopwatch stopwatch = new Stopwatch(); TestExecutor executor = new TestExecutor(TestEnvironment); Thread thread = new Thread(() => executor.RunTests(testCasesToRun.Select(DataConversionExtensions.ToVsTestCase), MockRunContext.Object, MockFrameworkHandle.Object)); stopwatch.Start(); thread.Start(); Thread.Sleep(1000); executor.Cancel(); thread.Join(); stopwatch.Stop(); stopwatch.ElapsedMilliseconds.Should().BeInRange(3000, // 1st test should be executed 4000); // 2nd test should not be executed }
public void RunTests_CancelingDuringTestExecution_StopsTestExecution() { List <TestCase> allTestCases = TestDataCreator.AllTestCasesOfSampleTests; List <TestCase> testCasesToRun = TestDataCreator.GetTestCasesOfSampleTests("Crashing.LongRunning", "LongRunningTests.Test3"); var stopwatch = new Stopwatch(); var runner = new SequentialTestRunner(MockFrameworkReporter.Object, TestEnvironment); var thread = new Thread(() => runner.RunTests(allTestCases, testCasesToRun, "", "", false, null)); stopwatch.Start(); thread.Start(); Thread.Sleep(1000); runner.Cancel(); thread.Join(); stopwatch.Stop(); stopwatch.ElapsedMilliseconds.Should().BeGreaterThan(2000); // 1st test should be executed stopwatch.ElapsedMilliseconds.Should().BeLessThan(3000); // 2nd test should not be executed }
public virtual void RunTests_TestDirectoryViaUserParams_IsPassedViaCommandLineArg() { TestCase testCase = TestDataCreator.GetTestCasesOfSampleTests("CommandArgs.TestDirectoryIsSet").First(); TestExecutor executor = new TestExecutor(TestEnvironment); executor.RunTests(testCase.ToVsTestCase().Yield(), MockRunContext.Object, MockFrameworkHandle.Object); MockFrameworkHandle.Verify(h => h.RecordEnd(It.IsAny <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>(), It.Is <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome>(to => to == Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome.Passed)), Times.Exactly(0)); MockFrameworkHandle.Verify(h => h.RecordEnd(It.IsAny <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>(), It.Is <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome>(to => to == Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome.Failed)), Times.Exactly(1)); MockFrameworkHandle.Reset(); MockOptions.Setup(o => o.AdditionalTestExecutionParam).Returns("-testdirectory=\"" + SettingsWrapper.TestDirPlaceholder + "\""); executor = new TestExecutor(TestEnvironment); executor.RunTests(testCase.ToVsTestCase().Yield(), MockRunContext.Object, MockFrameworkHandle.Object); MockFrameworkHandle.Verify(h => h.RecordEnd(It.IsAny <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>(), It.Is <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome>(to => to == Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome.Failed)), Times.Exactly(0)); MockFrameworkHandle.Verify(h => h.RecordEnd(It.IsAny <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>(), It.Is <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome>(to => to == Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome.Passed)), Times.Exactly(1)); }