示例#1
0
        private VSTestResult GetBasicResult(NUnitTestEvent resultNode, IEnumerable <XmlNode> outputNodes)
        {
            var vsTest = GetCachedTestCase(resultNode.Id);

            if (vsTest == null)
            {
                return(null);
            }

            var vsResult = new VSTestResult(vsTest)
            {
                DisplayName = vsTest.DisplayName,
                Outcome     = GetTestOutcome(resultNode),
                Duration    = resultNode.Duration
            };

            var startTime = resultNode.StartTime();

            if (startTime.Ok)
            {
                vsResult.StartTime = startTime.Time;
            }

            var endTime = resultNode.EndTime();

            if (endTime.Ok)
            {
                vsResult.EndTime = endTime.Time;
            }

            // TODO: Remove this when NUnit provides a better duration
            if (vsResult.Duration == TimeSpan.Zero && (vsResult.Outcome == TestOutcome.Passed || vsResult.Outcome == TestOutcome.Failed))
            {
                vsResult.Duration = TimeSpan.FromTicks(1);
            }

            vsResult.ComputerName = Environment.MachineName;

            FillResultFromOutputNodes(outputNodes, vsResult);

            // Add stdOut messages from TestFinished element to vstest result
            var output = resultNode.Output;

            if (!string.IsNullOrEmpty(output))
            {
                vsResult.Messages.Add(new TestResultMessage(TestResultMessage.StandardOutCategory, output));
            }

            var attachmentSet = ParseAttachments(resultNode.Node);

            if (attachmentSet.Attachments.Count > 0)
            {
                vsResult.Attachments.Add(attachmentSet);
            }

            return(vsResult);
        }
示例#2
0
 // Public for testing
 public TestOutcome GetTestOutcome(NUnitTestEvent resultNode)
 {
     return(resultNode.Result() switch
     {
         NUnitTestEvent.ResultType.Success => TestOutcome.Passed,
         NUnitTestEvent.ResultType.Failed => TestOutcome.Failed,
         NUnitTestEvent.ResultType.Skipped => (resultNode.IsIgnored ? TestOutcome.Skipped : TestOutcome.None),
         NUnitTestEvent.ResultType.Warning => adapterSettings.MapWarningTo,
         _ => TestOutcome.None
     });
示例#3
0
        // Public for testing
        public static TestOutcome GetTestOutcome(NUnitTestEvent resultNode)
        {
            switch (resultNode.Result())
            {
            case NUnitTestEvent.ResultType.Success:
                return(TestOutcome.Passed);

            case NUnitTestEvent.ResultType.Failed:
                return(TestOutcome.Failed);

            case NUnitTestEvent.ResultType.Skipped:
                return(resultNode.IsIgnored ? TestOutcome.Skipped : TestOutcome.None);

            case NUnitTestEvent.ResultType.Warning:
                return(TestOutcome.Skipped);

            default:
                return(TestOutcome.None);
            }
        }