Exemple #1
0
        private IEnumerable <TestResult> RunAllTests(IEnumerable <TestCase> testCases, Dictionary <string, string> envVars,
                                                     string runSettings, bool forCoverage)
        {
            using (var runCompleteSignal = new AutoResetEvent(false))
            {
                var eventHandler = new RunEventHandler(runCompleteSignal, _logger);
                var strykerVsTestHostLauncher1 = new StrykerVsTestHostLauncher(null, envVars, _id);
                if (_flags.HasFlag(OptimizationFlags.AbortTestOnKill) && !forCoverage)
                {
                    eventHandler.TestsFailed += Handler_TestsFailed;
                }

                if (testCases != null)
                {
                    var finalTestCases1 =
                        _discoveredTests.Where(discoveredTest => testCases.Any(test => test.Id == discoveredTest.Id));
                    _vsTestConsole.RunTestsWithCustomTestHost(finalTestCases1, runSettings, eventHandler, strykerVsTestHostLauncher1);
                }
                else
                {
                    _vsTestConsole.RunTestsWithCustomTestHost(_sources, runSettings, eventHandler, strykerVsTestHostLauncher1);
                }

                // Test host exited signal comes after the run complete
                strykerVsTestHostLauncher1.WaitProcessExit();

                // At this point, run must have complete. Check signal for true
                runCompleteSignal.WaitOne();

                eventHandler.TestsFailed -= Handler_TestsFailed;

                return(eventHandler.TestResults);
            }
        }
Exemple #2
0
        private IEnumerable <TestResult> RunAllTests(int?activeMutationId, string runSettings)
        {
            var runCompleteSignal   = new AutoResetEvent(false);
            var processExitedSignal = new AutoResetEvent(false);
            var handler             = new RunEventHandler(runCompleteSignal, _messages);
            var testHostLauncher    = new StrykerVsTestHostLauncher(() => processExitedSignal.Set(), activeMutationId);

            _vsTestConsole.RunTestsWithCustomTestHost(_sources, runSettings, handler, testHostLauncher);

            // Test host exited signal comes after the run complete
            processExitedSignal.WaitOne();

            // At this point, run must have complete. Check signal for true
            runCompleteSignal.WaitOne();

            return(handler.TestResults);
        }