private void DoRunTests(ICollection <TestCase> testCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle) { if (testCasesToRun.Count == 0) { return; } bool isRunningInsideVisualStudio = !string.IsNullOrEmpty(runContext.SolutionDirectory); var reporter = new VsTestFrameworkReporter(frameworkHandle, isRunningInsideVisualStudio, _logger); var debuggerAttacher = _debuggerAttacher ?? new MessageBasedDebuggerAttacher(_settings.DebuggingNamedPipeId, _logger); var processExecutorFactory = new DebuggedProcessExecutorFactory(frameworkHandle, debuggerAttacher); var exitCodeTestsAggregator = new ExitCodeTestsAggregator(); var exitCodeTestsReporter = new ExitCodeTestsReporter(reporter, exitCodeTestsAggregator, _settings, _logger); lock (_lock) { if (_canceled) { return; } _executor = new GoogleTestExecutor(_logger, _settings, processExecutorFactory, exitCodeTestsReporter); } _executor.RunTests(testCasesToRun, reporter, runContext.IsBeingDebugged); reporter.AllTestsFinished(); }
private void AssertDurationsFileIsCreated(bool parallelExecution) { string sampleTestsDurationsFile = TestResources.Tests_DebugX86 + GoogleTestConstants.DurationsExtension; RemoveFileIfNecessary(sampleTestsDurationsFile); string crashingTestsDurationsFile = TestResources.CrashingTests_DebugX86 + GoogleTestConstants.DurationsExtension; RemoveFileIfNecessary(crashingTestsDurationsFile); MockOptions.Setup(o => o.ParallelTestExecution).Returns(parallelExecution); MockOptions.Setup(o => o.MaxNrOfThreads).Returns(2); MockOptions.Setup(o => o.SolutionDir).Returns(TestResources.SampleTestsSolutionDir); var collectingReporter = new FakeFrameworkReporter(); var exitCodeTestsAggregator = new ExitCodeTestsAggregator(); var exitCodeTestsReporter = new ExitCodeTestsReporter(MockFrameworkReporter.Object, exitCodeTestsAggregator, MockOptions.Object, MockLogger.Object); var testExecutor = new GoogleTestExecutor(TestEnvironment.Logger, TestEnvironment.Options, ProcessExecutorFactory, exitCodeTestsReporter); testExecutor.RunTests(TestDataCreator.AllTestCasesExceptLoadTests, collectingReporter, false); sampleTestsDurationsFile.AsFileInfo() .Should() .Exist("Test execution should result in test durations"); var durations = new TestDurationSerializer().ReadTestDurations(TestDataCreator.AllTestCasesOfSampleTests); durations.Keys.Should().Contain( TestDataCreator.AllTestCasesOfSampleTests.Where(tc => collectingReporter.ReportedTestResults.Any(tr => tc.Equals(tr.TestCase) && (tr.Outcome == TestOutcome.Passed || tr.Outcome == TestOutcome.Failed)))); crashingTestsDurationsFile.AsFileInfo() .Should() .Exist("Test execution should result in test durations file"); durations = new TestDurationSerializer().ReadTestDurations(TestDataCreator.AllTestCasesOfHardCrashingTests); durations.Keys.Should().Contain(TestDataCreator.AllTestCasesOfHardCrashingTests.Where(tc => collectingReporter.ReportedTestResults.Any(tr => tc.Equals(tr.TestCase) && (tr.Outcome == TestOutcome.Passed || tr.Outcome == TestOutcome.Failed)))); }