コード例 #1
0
ファイル: NSpecController.cs プロジェクト: kina/NSpec
        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
ファイル: NSpecController.cs プロジェクト: kina/NSpec
        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));
        }
コード例 #3
0
ファイル: NSpecTestExplorer.cs プロジェクト: kina/NSpec
        NSpecExampleTest CreateGallioTestFrom(Example nspecExample)
        {
            try
            {
                NSpecExampleTest exampleTest = new NSpecExampleTest(nspecExample);

                return(exampleTest);
            }
            catch
            {
                throw new Exception(String.Format("Error adding example {0}", nspecExample.Spec));
            }
        }