Example #1
0
 private int GetNUnitIgnoredCount(TestExecutionResult testExecutionResult)
 {
     return(testExecutionResult.TestResults.Count(
                r => r.Outcome == "NotExecuted" &&
                (r.ErrorMessage?.Contains("Ignored scenario") == true ||
                 r.ErrorMessage?.Contains("Ignored feature") == true)));
 }
Example #2
0
        private TestExecutionResult CalculateNUnitTestExecutionResult(TestExecutionResult testExecutionResult)
        {
            testExecutionResult.Ignored = GetNUnitIgnoredCount(testExecutionResult);
            testExecutionResult.Pending = testExecutionResult.Total - testExecutionResult.Executed - testExecutionResult.Ignored;

            return(testExecutionResult);
        }
Example #3
0
        private TestExecutionResult CalculateXUnitTestExecutionResult(TestExecutionResult testExecutionResult)
        {
            testExecutionResult.Pending = GetXUnitPendingCount(testExecutionResult.Output);
            testExecutionResult.Failed -= testExecutionResult.Pending;
            testExecutionResult.Ignored = testExecutionResult.Total - testExecutionResult.Executed;

            return(testExecutionResult);
        }
Example #4
0
        private TestExecutionResult CalculateXUnitTestExecutionResult(TestExecutionResult testExecutionResult, XDocument trx)
        {
            testExecutionResult.Pending = GetXUnitPendingCount(trx.Element(_testRunElementName)?.Element(_resultsElementName));
            testExecutionResult.Failed -= testExecutionResult.Pending;
            testExecutionResult.Ignored = testExecutionResult.Total - testExecutionResult.Executed;

            return(testExecutionResult);
        }
Example #5
0
        private TestExecutionResult CalculateMsTestTestExecutionResult(TestExecutionResult testExecutionResult)
        {
            bool HasPendingError(TestResult r) => r.ErrorMessage != null && r.ErrorMessage.Contains("Assert.Inconclusive failed. One or more step definitions are not implemented yet.");

            testExecutionResult.Ignored = testExecutionResult.TestResults.Count(r => r.Outcome == "NotExecuted" && !HasPendingError(r));
            testExecutionResult.Pending = testExecutionResult.TestResults.Count(r => HasPendingError(r));

            return(testExecutionResult);
        }
Example #6
0
        private int GetNUnitIgnoredCount(TestExecutionResult testExecutionResult)
        {
            var elements = from testResult in testExecutionResult.TestResults
                           where testResult.Outcome == "NotExecuted"
                           where testResult.ErrorMessage?.Contains("Scenario ignored using @Ignore tag") == true ||
                           testResult.ErrorMessage?.Contains("Ignored feature") == true
                           select testResult;

            return(elements.Count());
        }
Example #7
0
        private TestExecutionResult CalculateMsTestTestExecutionResult(TestExecutionResult testExecutionResult)
        {
            testExecutionResult.Pending = testExecutionResult.TestResults
                                          .Where(r => r.ErrorMessage != null)
                                          .Select(r => r.ErrorMessage)
                                          .Count(m => m.Contains("Assert.Inconclusive failed"));
            testExecutionResult.Ignored = testExecutionResult.Total - testExecutionResult.Executed - testExecutionResult.Pending;

            return(testExecutionResult);
        }
Example #8
0
        private TestExecutionResult CalculateSpecRunTestExecutionResult(TestExecutionResult testExecutionResult)
        {
            bool FilterIgnored(TestResult testResult) => testResult.StdOut.Contains("-> Ignored");

            bool FilterPending(TestResult testResult) => testResult.StdOut.Contains("TechTalk.SpecRun.PendingTestException") ||
            testResult.StdOut.Contains("No matching step definition found for the step.");

            var testResultsWithOutput = testExecutionResult.TestResults.Where(tr => !(tr?.StdOut is null)).ToArray();

            testExecutionResult.Ignored = testResultsWithOutput.Where(FilterIgnored).Count();
            testExecutionResult.Pending = testResultsWithOutput.Where(FilterPending).Count();

            return(testExecutionResult);
        }
Example #9
0
        private TestExecutionResult CalculateMsTestTestExecutionResult(TestExecutionResult testExecutionResult)
        {
            testExecutionResult.Ignored = testExecutionResult.TestResults
                                          .Where(r => r.ErrorMessage != null)
                                          .Select(r => r.ErrorMessage)
                                          .Count(m => m.Contains("Assert.Inconclusive failed") && !m.Contains("One or more step definitions are not implemented yet"));


            testExecutionResult.Pending = testExecutionResult.TestResults
                                          .Where(r => r.ErrorMessage != null)
                                          .Select(r => r.ErrorMessage)
                                          .Count(m => m.Contains("Assert.Inconclusive failed. One or more step definitions are not implemented yet."));

            return(testExecutionResult);
        }
Example #10
0
        private TestExecutionResult CalculateUnitTestProviderSpecificTestExecutionResult(TestExecutionResult testExecutionResult, TestRunConfiguration testRunConfiguration)
        {
            switch (testRunConfiguration.UnitTestProvider)
            {
            case UnitTestProvider.xUnit: return(CalculateXUnitTestExecutionResult(testExecutionResult));

            case UnitTestProvider.MSTest: return(CalculateMsTestTestExecutionResult(testExecutionResult));

            case UnitTestProvider.NUnit3: return(CalculateNUnitTestExecutionResult(testExecutionResult));

            case UnitTestProvider.SpecRun: return(CalculateSpecRunTestExecutionResult(testExecutionResult));

            default: throw new NotSupportedException($"The specified unit test provider is not supported: {testRunConfiguration.UnitTestProvider}");
            }
        }