public void TestFinished(INUnitTestEventTestCase resultNode)
        {
            var testId = resultNode.Id;

            if (_outputNodes.TryGetValue(testId, out var outputNodes))
            {
                _outputNodes.Remove(testId);
            }

            var result = _testConverter.GetVsTestResults(resultNode, outputNodes ?? EmptyNodes);

            if (_settings.ConsoleOut == 1 && !string.IsNullOrEmpty(result.ConsoleOutput) && result.ConsoleOutput != NL)
            {
                _recorder.SendMessage(TestMessageLevel.Informational, result.ConsoleOutput);
            }
            if (_settings.ConsoleOut == 1 && !string.IsNullOrEmpty(resultNode.ReasonMessage))
            {
                _recorder.SendMessage(TestMessageLevel.Informational, $"{resultNode.Name}: {resultNode.ReasonMessage}");
            }

            _recorder.RecordEnd(result.TestCaseResult.TestCase, result.TestCaseResult.Outcome);
            foreach (var vsResult in result.TestResults)
            {
                _recorder.RecordResult(vsResult);
            }

            if (result.TestCaseResult.Outcome == TestOutcome.Failed && _settings.StopOnError)
            {
                executor.StopRun();
            }
        }
Beispiel #2
0
        public TestResultSet GetVsTestResults(INUnitTestEventTestCase resultNode, ICollection <INUnitTestEventTestOutput> outputNodes)
        {
            var results = new List <VSTestResult>();

            var testCaseResult = GetBasicResult(resultNode, outputNodes);

            if (testCaseResult != null)
            {
                switch (testCaseResult.Outcome)
                {
                case TestOutcome.Failed:
                case TestOutcome.NotFound:
                {
                    testCaseResult.ErrorMessage    = resultNode.Failure?.Message;
                    testCaseResult.ErrorStackTrace = resultNode.Failure?.Stacktrace ?? resultNode.StackTrace;
                    break;
                }

                case TestOutcome.Skipped:
                case TestOutcome.None:
                    testCaseResult.ErrorMessage = resultNode.ReasonMessage;
                    testCaseResult.Messages.Add(new TestResultMessage(TestResultMessage.StandardOutCategory, resultNode.ReasonMessage));
                    break;

                default:
                {
                    if (adapterSettings.ConsoleOut > 0 && !string.IsNullOrEmpty(resultNode.ReasonMessage))
                    {
                        testCaseResult.Messages.Add(new TestResultMessage(TestResultMessage.StandardOutCategory, resultNode.ReasonMessage));
                    }
                    break;
                }
                }

                results.Add(testCaseResult);
            }

            if (results.Count == 0)
            {
                var result = MakeTestResultFromLegacyXmlNode(resultNode, outputNodes);
                if (result != null)
                {
                    results.Add(result);
                }
            }
            return(new TestResultSet {
                TestCaseResult = testCaseResult, TestResults = results, ConsoleOutput = resultNode.Output
            });
        }