Example #1
0
 protected static TestOutcome GetTestOutcome(SpecResult result)
 {
     if (result.Skipped)
     {
         return TestOutcome.Skipped;
     }
     return result.Success ? TestOutcome.Passed : TestOutcome.Failed;
 }
Example #2
0
        protected virtual TestResult GetResult(TestCase testCase, SpecResult result, IFrameworkHandle frameworkHandle)
        {
            var testResult = new TestResult(testCase)
            {
                ComputerName = Environment.MachineName,
                DisplayName = result.Name,
                Outcome = GetTestOutcome(result),
                Duration = TimeSpan.FromTicks(Math.Max(Convert.ToInt64((result.Time ?? 0) * TimeSpan.TicksPerMillisecond), 1))
            };

            if (result.Failures != null && result.Failures.Any())
            {
                var failure = result.Failures.First();
                testResult.ErrorMessage = failure.message;
                testResult.ErrorStackTrace = string.Join(Environment.NewLine, failure.stack);
                foreach (var extraFailure in result.Failures.Skip(1))
                {
                    testResult.Messages.Add(new TestResultMessage(TestResultMessage.AdditionalInfoCategory,
                        string.Join(Environment.NewLine, extraFailure.message, string.Join(Environment.NewLine, extraFailure.stack))
                    ));
                }
                if (result.Log != null && result.Log.Any())
                {
                    testResult.Messages.Add(new TestResultMessage(TestResultMessage.StandardErrorCategory, string.Join(Environment.NewLine, result.Log)));
                }
            }
            else if (result.Log != null && result.Log.Any())
            {
                testResult.Messages.Add(new TestResultMessage(TestResultMessage.StandardErrorCategory, string.Join(Environment.NewLine, result.Log)));
                testResult.ErrorMessage = string.Join(Environment.NewLine, result.Log);
            }

            if (!string.IsNullOrWhiteSpace(result.Output))
            {
                testResult.Messages.Add(new TestResultMessage(TestResultMessage.StandardOutCategory, result.Output));
            }

            return testResult;
        }