Esempio n. 1
0
        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 );
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
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 );
        }