private List <TestResult> CollectTestResults(IEnumerable <TestCase> testCasesRun, string resultXmlFile, List <string> consoleOutput, string baseDir)
        {
            var testResults = new List <TestResult>();

            TestCase[] testCasesRunAsArray = testCasesRun as TestCase[] ?? testCasesRun.ToArray();
            var        xmlParser           = new XmlTestResultParser(testCasesRunAsArray, resultXmlFile, _testEnvironment, baseDir);
            var        consoleParser       = new StandardOutputTestResultParser(testCasesRunAsArray, consoleOutput, _testEnvironment, baseDir);

            testResults.AddRange(xmlParser.GetTestResults());
            _testEnvironment.DebugInfo($"Collected {testResults.Count} test results from XML result file '{resultXmlFile}'");

            if (testResults.Count < testCasesRunAsArray.Length)
            {
                List <TestResult> consoleResults = consoleParser.GetTestResults();
                int nrOfCollectedTestResults     = 0;
                // ReSharper disable once AccessToModifiedClosure
                foreach (TestResult testResult in consoleResults.Where(tr => !testResults.Exists(tr2 => tr.TestCase.FullyQualifiedName == tr2.TestCase.FullyQualifiedName)))
                {
                    testResults.Add(testResult);
                    nrOfCollectedTestResults++;
                }
                _testEnvironment.DebugInfo($"Collected {nrOfCollectedTestResults} test results from console output");
            }

            if (testResults.Count < testCasesRunAsArray.Length)
            {
                string errorMessage, errorStackTrace = null;
                if (consoleParser.CrashedTestCase == null)
                {
                    errorMessage = "";
                }
                else
                {
                    errorMessage    = $"reason is probably a crash of test {consoleParser.CrashedTestCase.DisplayName}";
                    errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                               consoleParser.CrashedTestCase.CodeFilePath, consoleParser.CrashedTestCase.LineNumber.ToString());
                }
                int nrOfCreatedTestResults = 0;
                // ReSharper disable once AccessToModifiedClosure
                foreach (TestCase testCase in testCasesRunAsArray.Where(tc => !testResults.Exists(tr => tr.TestCase.FullyQualifiedName == tc.FullyQualifiedName)))
                {
                    testResults.Add(new TestResult(testCase)
                    {
                        ComputerName    = Environment.MachineName,
                        Outcome         = TestOutcome.Skipped,
                        ErrorMessage    = errorMessage,
                        ErrorStackTrace = errorStackTrace
                    });
                    nrOfCreatedTestResults++;
                }
                _testEnvironment.DebugInfo($"Created {nrOfCreatedTestResults} test results for tests which were neither found in result XML file nor in console output");
            }

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

            return(testResults);
        }
        private void CreateMissingResults(TestCase[] testCases, TestCase crashedTestCase, List <TestResult> testResults)
        {
            var errorMessage    = $"reason is probably a crash of test {crashedTestCase.DisplayName}";
            var errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                           crashedTestCase.CodeFilePath, crashedTestCase.LineNumber.ToString());

            testResults.AddRange(testCases.Select(testCase =>
                                                  CreateTestResult(testCase, TestOutcome.Skipped, errorMessage, errorStackTrace)));
            if (testCases.Length > 0)
            {
                _logger.DebugInfo($"{_threadName}Created {testCases.Length} test results for tests which were neither found in result XML file nor in console output");
            }
        }
Esempio n. 3
0
        private List <TestResult> CollectTestResults(IEnumerable <TestCase> testCasesRun, string resultXmlFile, List <string> consoleOutput, string baseDir)
        {
            List <TestResult> testResults = new List <TestResult>();

            TestCase[]                     testCasesRunAsArray = testCasesRun as TestCase[] ?? testCasesRun.ToArray();
            XmlTestResultParser            xmlParser           = new XmlTestResultParser(testCasesRunAsArray, resultXmlFile, TestEnvironment, baseDir);
            StandardOutputTestResultParser consoleParser       = new StandardOutputTestResultParser(testCasesRunAsArray, consoleOutput, TestEnvironment, baseDir);

            testResults.AddRange(xmlParser.GetTestResults());

            if (testResults.Count < testCasesRunAsArray.Length)
            {
                List <TestResult> consoleResults = consoleParser.GetTestResults();
                foreach (TestResult testResult in consoleResults.Where(tr => !testResults.Exists(tr2 => tr.TestCase.FullyQualifiedName == tr2.TestCase.FullyQualifiedName)))
                {
                    testResults.Add(testResult);
                }
            }

            if (testResults.Count < testCasesRunAsArray.Length)
            {
                string errorMessage, errorStackTrace = null;
                if (consoleParser.CrashedTestCase == null)
                {
                    errorMessage = "";
                }
                else
                {
                    errorMessage    = "reason is probably a crash of test " + consoleParser.CrashedTestCase.DisplayName;
                    errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                               consoleParser.CrashedTestCase.CodeFilePath, consoleParser.CrashedTestCase.LineNumber.ToString());
                }
                foreach (TestCase testCase in testCasesRunAsArray.Where(tc => !testResults.Exists(tr => tr.TestCase.FullyQualifiedName == tc.FullyQualifiedName)))
                {
                    testResults.Add(new TestResult(testCase)
                    {
                        ComputerName    = Environment.MachineName,
                        Outcome         = TestOutcome.Skipped,
                        ErrorMessage    = errorMessage,
                        ErrorStackTrace = errorStackTrace
                    });
                }
            }

            return(testResults);
        }
Esempio n. 4
0
        private void CreateMissingResults(TestCase[] testCases, TestCase crashedTestCase, List <TestResult> testResults)
        {
            var errorMessage    = $"reason is probably a crash of test {crashedTestCase.DisplayName}";
            var errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                           crashedTestCase.CodeFilePath, crashedTestCase.LineNumber.ToString());

            foreach (TestCase testCase in testCases)
            {
                testResults.Add(new TestResult(testCase)
                {
                    ComputerName    = Environment.MachineName,
                    Outcome         = TestOutcome.Skipped,
                    ErrorMessage    = errorMessage,
                    ErrorStackTrace = errorStackTrace
                });
            }
            if (testCases.Length > 0)
            {
                _logger.DebugInfo($"{_threadName}Created {testCases.Length} test results for tests which were neither found in result XML file nor in console output");
            }
        }
Esempio n. 5
0
        private void CreateMissingResults(TestCase[] testCases, TestCase crashedTestCase, List <TestResult> testResults)
        {
            var errorMessage    = String.Format(Resources.CrashTest, crashedTestCase.DisplayName);
            var errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                           crashedTestCase.CodeFilePath, crashedTestCase.LineNumber.ToString());

            foreach (TestCase testCase in testCases)
            {
                testResults.Add(new TestResult(testCase)
                {
                    ComputerName    = Environment.MachineName,
                    Outcome         = TestOutcome.Skipped,
                    ErrorMessage    = errorMessage,
                    ErrorStackTrace = errorStackTrace
                });
            }
            if (testCases.Length > 0)
            {
                _logger.DebugInfo(String.Format(Resources.CreatedTestResults, _threadName, testCases.Length));
            }
        }