示例#1
0
        TestResult RunTest(NSpecContextTest contextTest, NSpecExampleTest exampleTest,
                           ITestCommand testCommand, TestStep testStep)
        {
            ITestContext testContext = testCommand.StartPrimaryChildStep(testStep);
            TestOutcome  outcome     = TestOutcome.Passed;

            if (exampleTest.Example.Pending)
            {
                outcome = TestOutcome.Pending;
                testContext.AddMetadata(MetadataKeys.PendingReason, "Needs to be implemented");
            }
            else
            {
                contextTest.Context.Exercise(exampleTest.Example, contextTest.Context.GetInstance());

                if (exampleTest.Example.Exception != null)
                {
                    TestLog.Failures.WriteException(ConvertException(exampleTest.Example.Exception));
                    TestLog.Failures.Flush();

                    outcome = TestOutcome.Failed;
                }
            }

            return(testContext.FinishStep(outcome, null));
        }
示例#2
0
 /// <summary>
 /// Adds metadata to the step that is running in the context.
 /// </summary>
 /// <param name="metadataKey">The metadata key.</param>
 /// <param name="metadataValue">The metadata value.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="metadataKey"/>
 /// or <paramref name="metadataValue"/> is null.</exception>
 public void AddMetadata(string metadataKey, string metadataValue)
 {
     inner.AddMetadata(metadataKey, metadataValue);
 }