Ejemplo n.º 1
0
        public void Invalid_step_descriptors_should_make_composite_failing_immediately_without_execution()
        {
            TestCompositeStep Composite_step() => new TestCompositeStep(
                TestStep.Create(Step_that_should_not_run),
                StepDescriptor.CreateInvalid(new Exception("reason1")),
                StepDescriptor.CreateInvalid(new Exception("reason2")));

            var ex = Assert.Throws <AggregateException>(() => _runner.Test()
                                                        .TestScenario(
                                                            TestStep.CreateComposite(Composite_step),
                                                            TestStep.Create(Step_that_should_not_run)));

            Assert.That(ex.InnerExceptions.Select(x => x.Message).ToArray(),
                        Is.EqualTo(new[] { "Sub-steps initialization failed.", "reason1", "reason2" }));

            var mainSteps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps().ToArray();

            StepResultExpectation.AssertEqual(mainSteps[0].GetSubSteps(),
                                              new StepResultExpectation("1.", 1, 3, "Step that should not run", ExecutionStatus.NotRun),
                                              new StepResultExpectation("1.", 2, 3, "<INVALID STEP>", ExecutionStatus.Failed, "Step 1.2: reason1"),
                                              new StepResultExpectation("1.", 3, 3, "<INVALID STEP>", ExecutionStatus.Failed, "Step 1.3: reason2"));
            Assert.That(mainSteps[1].Status, Is.EqualTo(ExecutionStatus.NotRun));
        }
Ejemplo n.º 2
0
        public void Steps_should_get_access_to_DI_container_via_GetDependencyResolver()
        {
            var resolvers = new List <IDependencyResolver>();

            void Step1()
            {
                resolvers.Add(StepExecution.Current.GetScenarioDependencyResolver());
            }

            void Step3()
            {
                resolvers.Add(StepExecution.Current.GetScenarioDependencyResolver());
            }

            void Step4()
            {
                resolvers.Add(StepExecution.Current.GetScenarioDependencyResolver());
            }

            TestCompositeStep Step2()
            {
                resolvers.Add(StepExecution.Current.GetScenarioDependencyResolver());
                return(TestCompositeStep.Create(Step3, Step4));
            }

            GetFeatureRunner().GetBddRunner(this).Test().TestScenario(TestStep.CreateSync(Step1), TestStep.CreateComposite(Step2));

            Assert.That(resolvers.Count, Is.EqualTo(4));
            Assert.That(resolvers.Any(x => x == null), Is.False);
            Assert.That(resolvers.Distinct().Count(), Is.EqualTo(1));
        }