private TestResult RunContext(NSpecContextTest contextTest, ITestCommand command, TestStep testStep) { ITestContext testContext = command.StartPrimaryChildStep(testStep); TestOutcome outcome = TestOutcome.Passed; foreach (ITestCommand testCommand in command.Children) { NSpecExampleTest exampleTest = testCommand.Test as NSpecExampleTest; if (exampleTest == null) { continue; } outcome = outcome.CombineWith(this.RunTest(contextTest, exampleTest, testCommand, testContext.TestStep).Outcome); } foreach (ITestCommand testCommand in command.Children) { NSpecContextTest contextTestChild = testCommand.Test as NSpecContextTest; if (contextTestChild == null) { continue; } outcome = outcome.CombineWith(this.RunContext(contextTestChild, testCommand, testContext.TestStep).Outcome); } return(testContext.FinishStep(outcome, null)); }
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)); }
NSpecContextTest CreateGallioTestFrom(Context nspecContext) { NSpecContextTest contextTest = new NSpecContextTest(nspecContext); nspecContext.Examples.Do(e => contextTest.AddChild(this.CreateGallioTestFrom(e))); nspecContext.Contexts.Do(c => contextTest.AddChild(this.CreateGallioTestFrom(c))); return(contextTest); }
private TestResult RunAssembly(ITestCommand command, TestStep rootStep) { ITestContext assemblyContext = command.StartPrimaryChildStep(rootStep); TestOutcome outcome = TestOutcome.Passed; foreach (ITestCommand contextCommand in command.Children) { NSpecContextTest contextTest = contextCommand.Test as NSpecContextTest; if (contextTest == null) { continue; } var contextResult = this.RunContext(contextTest, contextCommand, assemblyContext.TestStep); outcome = outcome.CombineWith(contextResult.Outcome); assemblyContext.SetInterimOutcome(outcome); } return(assemblyContext.FinishStep(outcome, null)); }