private IEnumerable <TestResult> TryRunTests(string executable, string workingDir, bool isBeingDebugged,
                                                     IDebuggedProcessLauncher debuggedLauncher, CommandLineGenerator.Args arguments, string resultXmlFile, IProcessExecutor executor,
                                                     StreamingStandardOutputTestResultParser streamingParser)
        {
            List <string> consoleOutput;

            if (_settings.UseNewTestExecutionFramework)
            {
                DebugUtils.AssertIsNotNull(executor, nameof(executor));
                consoleOutput = RunTestExecutableWithNewFramework(executable, workingDir, arguments, executor, streamingParser);
            }
            else
            {
                _processLauncher = new TestProcessLauncher(_logger, _settings, isBeingDebugged);
                consoleOutput    =
                    _processLauncher.GetOutputOfCommand(workingDir, executable, arguments.CommandLine,
                                                        _settings.PrintTestOutput && !_settings.ParallelTestExecution, false,
                                                        debuggedLauncher);
            }

            var remainingTestCases =
                arguments.TestCases.Except(streamingParser.TestResults.Select(tr => tr.TestCase));
            var testResults = new TestResultCollector(_logger, _threadName)
                              .CollectTestResults(remainingTestCases, resultXmlFile, consoleOutput, streamingParser.CrashedTestCase);

            testResults = testResults.OrderBy(tr => tr.TestCase.FullyQualifiedName).ToList();

            return(testResults);
        }
        // ReSharper disable once UnusedParameter.Local
        private void RunTestsFromExecutable(string executable, string workingDir,
                                            IEnumerable <TestCase> allTestCases, IEnumerable <TestCase> testCasesToRun, string baseDir, string userParameters,
                                            bool isBeingDebugged, IDebuggedProcessLauncher debuggedLauncher)
        {
            string resultXmlFile = Path.GetTempFileName();
            var    serializer    = new TestDurationSerializer();

            var generator = new CommandLineGenerator(allTestCases, testCasesToRun, executable.Length, userParameters, resultXmlFile, _testEnvironment);

            foreach (CommandLineGenerator.Args arguments in generator.GetCommandLines())
            {
                if (_canceled)
                {
                    break;
                }

                _frameworkReporter.ReportTestsStarted(arguments.TestCases);
                List <string>            consoleOutput = new TestProcessLauncher(_testEnvironment, isBeingDebugged).GetOutputOfCommand(workingDir, executable, arguments.CommandLine, _testEnvironment.Options.PrintTestOutput && !_testEnvironment.Options.ParallelTestExecution, false, debuggedLauncher);
                IEnumerable <TestResult> results       = CollectTestResults(arguments.TestCases, resultXmlFile, consoleOutput, baseDir);

                Stopwatch stopwatch = Stopwatch.StartNew();
                _frameworkReporter.ReportTestResults(results);
                stopwatch.Stop();
                _testEnvironment.DebugInfo($"Reported {results.Count()} test results to VS, executable: '{executable}', duration: {stopwatch.Elapsed}");

                serializer.UpdateTestDurations(results);
            }
        }
        private IEnumerable <TestResult> TryRunTests(string executable, string workingDir, string baseDir, bool isBeingDebugged,
                                                     IDebuggedProcessLauncher debuggedLauncher, CommandLineGenerator.Args arguments, string resultXmlFile, IProcessExecutor executor,
                                                     TestResultSplitter splitter)
        {
            List <string> consoleOutput;

            if (_settings.UseNewTestExecutionFramework)
            {
                DebugUtils.AssertIsNotNull(executor, nameof(executor));
                consoleOutput = RunTestExecutableWithNewFramework(executable, workingDir, arguments, executor, splitter);
            }
            else
            {
                consoleOutput =
                    new TestProcessLauncher(_logger, _settings, isBeingDebugged)
                    .GetOutputOfCommand(workingDir, executable, arguments.CommandLine,
                                        _settings.PrintTestOutput && !_settings.ParallelTestExecution, false,
                                        debuggedLauncher);
            }

            var remainingTestCases =
                arguments.TestCases.Except(splitter.TestResults.Select(tr => tr.TestCase));

            return(CollectTestResults(remainingTestCases, resultXmlFile, consoleOutput, baseDir, splitter.CrashedTestCase));
        }
Example #4
0
        // ReSharper disable once UnusedParameter.Local
        private void RunTestsFromExecutable(string executable,
                                            IEnumerable <TestCase> allTestCases, IEnumerable <TestCase> testCasesToRun, string baseDir, string userParameters,
                                            bool isBeingDebugged, IDebuggedProcessLauncher debuggedLauncher)
        {
            string resultXmlFile = Path.GetTempFileName();
            string workingDir    = Path.GetDirectoryName(executable);
            var    serializer    = new TestDurationSerializer();

            var generator = new CommandLineGenerator(allTestCases, testCasesToRun, executable.Length, userParameters, resultXmlFile, TestEnvironment);

            foreach (CommandLineGenerator.Args arguments in generator.GetCommandLines())
            {
                if (Canceled)
                {
                    break;
                }

                FrameworkReporter.ReportTestsStarted(arguments.TestCases);

                TestEnvironment.DebugInfo("Executing command '" + executable + " " + arguments.CommandLine + "'.");
                List <string>            consoleOutput = new TestProcessLauncher(TestEnvironment, isBeingDebugged).GetOutputOfCommand(workingDir, executable, arguments.CommandLine, TestEnvironment.Options.PrintTestOutput && !TestEnvironment.Options.ParallelTestExecution, false, debuggedLauncher);
                IEnumerable <TestResult> results       = CollectTestResults(arguments.TestCases, resultXmlFile, consoleOutput, baseDir);

                FrameworkReporter.ReportTestResults(results);
                serializer.UpdateTestDurations(results);
            }
        }
#pragma warning restore 162

        private string RunExecutableAndGetResultsFile(string arguments)
        {
            string command    = VsExperimentalInstance.GetVsTestConsolePath(VsExperimentalInstance.Versions.VS2015);
            string workingDir = "";

            var           launcher = new TestProcessLauncher();
            List <string> standardOut;
            List <string> standardErr;

            launcher.GetOutputStreams(workingDir, command, arguments, out standardOut, out standardErr);

            return(ParseResultsFileFromOutput(standardOut));
        }
Example #6
0
#pragma warning restore 162

        private string RunExecutableAndGetResultsFile(string arguments)
        {
            string command = TestResources.GetVsTestConsolePath(TestMetadata.VersionUnderTest);

            command.AsFileInfo().Should().Exist();

            string workingDir = "";

            var           launcher = new TestProcessLauncher();
            List <string> standardOut, standardErr;

            launcher.GetOutputStreams(workingDir, command, arguments, out standardOut, out standardErr);

            return(ParseResultsFileFromOutput(standardOut));
        }
#pragma warning restore 162

        private string RunExecutableAndGetResultsFile(string arguments)
        {
            string command = TestResources.GetVsTestConsolePath(TestMetadata.VersionUnderTest);

            command.AsFileInfo().Should().Exist();

            string workingDir = "";

            var launcher = new TestProcessLauncher();

            launcher.GetOutputStreams(workingDir, command, arguments, out var standardOut, out _, out var allOutput);
            _completeOutput = $"Console output:{Environment.NewLine}{string.Join(Environment.NewLine, allOutput)}";

            return(ParseResultsFileFromOutput(standardOut));
        }
Example #8
0
        public static string RunExecutableAndGetOutput(string solutionFile, string arguments)
        {
            string command    = TestResources.GetVsTestConsolePath(TestMetadata.VersionUnderTest);
            string workingDir = "";

            var launcher = new TestProcessLauncher();

            launcher.GetOutputStreams(workingDir, command, arguments, out List <string> standardOut, out var standardErr);

            string resultString = string.Join("\n", standardOut) + "\n\n" + string.Join("\n", standardErr);
            // ReSharper disable once AssignNullToNotNullAttribute
            string baseDir = Directory.GetParent(Path.GetDirectoryName(solutionFile)).FullName;

            resultString = NormalizeOutput(resultString, baseDir);

            return(resultString);
        }
Example #9
0
        public static string RunExecutableAndGetOutput(string solutionFile, string arguments)
        {
            string command    = VsExperimentalInstance.GetVsTestConsolePath(VsExperimentalInstance.Versions.VS2015);
            string workingDir = "";

            TestProcessLauncher launcher = new TestProcessLauncher();
            List <string>       standardOut;
            List <string>       standardErr;

            launcher.GetOutputStreams(workingDir, command, arguments, out standardOut, out standardErr);

            string resultString = string.Join("\n", standardOut) + "\n\n" + string.Join("\n", standardErr);
            // ReSharper disable once AssignNullToNotNullAttribute
            string baseDir = Directory.GetParent(Path.GetDirectoryName(solutionFile)).FullName;

            resultString = NormalizeOutput(resultString, baseDir);

            return(resultString);
        }