public void Runner_should_properly_capture_status_from_multiassert_steps()
        {
            Assert.Throws <AggregateException>(() => _runner.Test().TestGroupScenario(Multiassert_ignoring_steps, Multiassert_failing_composite, Passing_composite));

            var scenario = _feature.GetFeatureResult().GetScenarios().Single();

            Assert.That(scenario.Status, Is.EqualTo(ExecutionStatus.Failed));

            var steps = scenario.GetSteps().ToArray();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 3, "Multiassert ignoring steps", ExecutionStatus.Ignored, $"Step 1.1: ignoring{Environment.NewLine}Step 1.2: ignoring"),
                                              new StepResultExpectation(2, 3, "Multiassert failing composite", ExecutionStatus.Failed, $"Step 2.1: failing{Environment.NewLine}Step 2.2: failing"),
                                              new StepResultExpectation(3, 3, "Passing composite", ExecutionStatus.Passed)
                                              );

            StepResultExpectation.AssertEqual(steps[0].GetSubSteps(),
                                              new StepResultExpectation("1.", 1, 3, "Ignoring step", ExecutionStatus.Ignored, "Step 1.1: ignoring"),
                                              new StepResultExpectation("1.", 2, 3, "Ignoring step", ExecutionStatus.Ignored, "Step 1.2: ignoring"),
                                              new StepResultExpectation("1.", 3, 3, "Passing step", ExecutionStatus.Passed)
                                              );

            StepResultExpectation.AssertEqual(steps[1].GetSubSteps(),
                                              new StepResultExpectation("2.", 1, 3, "Failing step", ExecutionStatus.Failed, "Step 2.1: failing"),
                                              new StepResultExpectation("2.", 2, 3, "Failing step", ExecutionStatus.Failed, "Step 2.2: failing"),
                                              new StepResultExpectation("2.", 3, 3, "Passing step", ExecutionStatus.Passed)
                                              );

            StepResultExpectation.AssertEqual(steps[2].GetSubSteps(),
                                              new StepResultExpectation("3.", 1, 2, "Passing step", ExecutionStatus.Passed),
                                              new StepResultExpectation("3.", 2, 2, "Passing step", ExecutionStatus.Passed)
                                              );
        }
示例#2
0
        public void Should_collect_scenario_result_for_failed_parameterized_steps()
        {
            try
            {
                _subject.RunScenario(
                    given => Customer_has_bought_product("wooden desk"),
                    and => Product_has_usage_marks("wooden desk"),
                    when => Customer_gives_it_back(),
                    then => Product_is_not_accepted("wooden desk"));
            }
            catch { }

            var result = _subject.Result.Scenarios.Single();

            Assert.That(result.Name, Is.EqualTo("Should collect scenario result for failed parameterized steps"));
            Assert.That(result.Status, Is.EqualTo(ResultStatus.Failed));
            Assert.That(result.StatusDetails, Is.EqualTo("Step 2: Product usage verification is not implemented yet"));
            Assert.That(result.Label, Is.Null);
            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "GIVEN Customer has bought product \"wooden desk\"", ResultStatus.Passed),
                new StepResultExpectation(2, "AND Product \"wooden desk\" has usage marks", ResultStatus.Failed, "Product usage verification is not implemented yet"),
                new StepResultExpectation(3, "WHEN Customer gives it back", ResultStatus.NotRun),
                new StepResultExpectation(4, "THEN Product \"wooden desk\" is not accepted", ResultStatus.NotRun)
            });
        }
示例#3
0
        public void It_should_infer_and_capture_default_step_types()
        {
            _runner.Test().TestScenario(
                Setup_before_steps,
                Setup_before_steps,
                Given_step_one,
                Given_step_one,
                When_step_two,
                When_step_two,
                Then_step_three,
                Then_step_four,
                Then_step_five,
                Some_step
                );

            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 10, "SETUP before steps", ExecutionStatus.Passed),
                                              new StepResultExpectation(2, 10, "AND before steps", ExecutionStatus.Passed),
                                              new StepResultExpectation(3, 10, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation(4, 10, "AND step one", ExecutionStatus.Passed),
                                              new StepResultExpectation(5, 10, "WHEN step two", ExecutionStatus.Passed),
                                              new StepResultExpectation(6, 10, "AND step two", ExecutionStatus.Passed),
                                              new StepResultExpectation(7, 10, "THEN step three", ExecutionStatus.Passed),
                                              new StepResultExpectation(8, 10, "AND step four", ExecutionStatus.Passed),
                                              new StepResultExpectation(9, 10, "AND step five", ExecutionStatus.Passed),
                                              new StepResultExpectation(10, 10, "Some step", ExecutionStatus.Passed)
                                              );
        }
示例#4
0
        public void It_should_capture_predefined_step_types()
        {
            _runner.Test().TestScenario(
                TestStep.CreateWithTypeAsync("setup", Some_step),
                TestStep.CreateWithTypeAsync("setup", Some_step),
                TestStep.CreateWithTypeAsync("given", Some_step),
                TestStep.CreateWithTypeAsync("given", Some_step),
                TestStep.CreateWithTypeAsync("when", Some_step),
                TestStep.CreateWithTypeAsync("when", Some_step),
                TestStep.CreateWithTypeAsync("then", Some_step),
                TestStep.CreateWithTypeAsync("then", Some_step),
                TestStep.CreateWithTypeAsync("something else", Some_step),
                TestStep.CreateWithTypeAsync("something else", Some_step)
                );

            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 10, "SETUP Some step", ExecutionStatus.Passed),
                                              new StepResultExpectation(2, 10, "AND Some step", ExecutionStatus.Passed),
                                              new StepResultExpectation(3, 10, "GIVEN Some step", ExecutionStatus.Passed),
                                              new StepResultExpectation(4, 10, "AND Some step", ExecutionStatus.Passed),
                                              new StepResultExpectation(5, 10, "WHEN Some step", ExecutionStatus.Passed),
                                              new StepResultExpectation(6, 10, "AND Some step", ExecutionStatus.Passed),
                                              new StepResultExpectation(7, 10, "THEN Some step", ExecutionStatus.Passed),
                                              new StepResultExpectation(8, 10, "AND Some step", ExecutionStatus.Passed),
                                              new StepResultExpectation(9, 10, "SOMETHING ELSE Some step", ExecutionStatus.Passed),
                                              new StepResultExpectation(10, 10, "AND Some step", ExecutionStatus.Passed)
                                              );
        }
示例#5
0
        public void Runner_should_properly_associate_steps_to_the_group()
        {
            Assert.DoesNotThrow(() => _runner.Test().TestGroupScenario(Passing_step_group, Composite_group));
            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps().ToArray();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 2, "Passing step group", ExecutionStatus.Passed),
                                              new StepResultExpectation(2, 2, "Composite group", ExecutionStatus.Bypassed, $"Step 2.2.2: {BypassReason}"));

            StepResultExpectation.AssertEqual(steps[0].GetSubSteps(),
                                              new StepResultExpectation("1.", 1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation("1.", 2, 3, "WHEN step two", ExecutionStatus.Passed),
                                              new StepResultExpectation("1.", 3, 3, "THEN step three", ExecutionStatus.Passed)
                                              );

            StepResultExpectation.AssertEqual(steps[1].GetSubSteps().ElementAt(0).GetSubSteps(),
                                              new StepResultExpectation("2.1.", 1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation("2.1.", 2, 3, "WHEN step two with comment", ExecutionStatus.Passed, null, CommentReason),
                                              new StepResultExpectation("2.1.", 3, 3, "THEN step three", ExecutionStatus.Passed)
                                              );
            StepResultExpectation.AssertEqual(steps[1].GetSubSteps().ElementAt(1).GetSubSteps(),
                                              new StepResultExpectation("2.2.", 1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation("2.2.", 2, 3, "WHEN step two is bypassed", ExecutionStatus.Bypassed, $"Step 2.2.2: {BypassReason}"),
                                              new StepResultExpectation("2.2.", 3, 3, "THEN step three", ExecutionStatus.Passed)
                                              );
        }
示例#6
0
        public void It_should_collect_scenario_result_for_ignored_scenario_with_bypassed_steps()
        {
            try
            {
                _subject.RunScenario(Step_one, Step_with_bypass, Step_with_bypass2, Step_with_ignore_assertion, Step_two);
            }
            catch { }

            var result = _subject.Result.Scenarios.Single();

            Assert.That(result.Name, Is.EqualTo("It should collect scenario result for ignored scenario with bypassed steps"));
            Assert.That(result.Status, Is.EqualTo(ResultStatus.Ignored));
            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "Step one", ResultStatus.Passed),
                new StepResultExpectation(2, "Step with bypass", ResultStatus.Bypassed, BypassReason),
                new StepResultExpectation(3, "Step with bypass2", ResultStatus.Bypassed, BypassReason2),
                new StepResultExpectation(4, "Step with ignore assertion", ResultStatus.Ignored, IgnoreReason),
                new StepResultExpectation(5, "Step two", ResultStatus.NotRun)
            });
            Assert.That(result.StatusDetails, Is.EqualTo(
                            "Step 2: " + BypassReason + Environment.NewLine +
                            "Step 3: " + BypassReason2 + Environment.NewLine +
                            "Step 4: " + IgnoreReason));
        }
示例#7
0
        public void Should_capture_constant_parameters_of_different_type_even_if_step_was_not_executed_yet()
        {
            try
            {
                _subject.RunScenario(
                    call => Ignored_method(),
                    call => Method_with_parameter("abc"),
                    call => Method_with_parameter(1),
                    call => Method_with_parameter(3.5),
                    call => Method_with_parameter(null),
                    call => Method_with_parameter(22.67m),
                    call => Method_with_parameter('a'),
                    call => Method_with_parameter(typeof(object)),
                    call => Method_with_parameter_and_OTHER("abc", new DateTime(2014, 05, 31)));
            }
            catch { }

            var result = _subject.Result.Scenarios.Single();

            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "CALL Ignored method", ResultStatus.Ignored, "ignored"),
                new StepResultExpectation(2, "CALL Method with parameter \"abc\"", ResultStatus.NotRun),
                new StepResultExpectation(3, "CALL Method with parameter \"1\"", ResultStatus.NotRun),
                new StepResultExpectation(4, "CALL Method with parameter \"3.5\"", ResultStatus.NotRun),
                new StepResultExpectation(5, "CALL Method with parameter \"\"", ResultStatus.NotRun),
                new StepResultExpectation(6, "CALL Method with parameter \"22.67\"", ResultStatus.NotRun),
                new StepResultExpectation(7, "CALL Method with parameter \"a\"", ResultStatus.NotRun),
                new StepResultExpectation(8, "CALL Method with parameter \"System.Object\"", ResultStatus.NotRun),
                new StepResultExpectation(9, "CALL Method with parameter \"abc\" and \"<?>\"", ResultStatus.NotRun)
            });
        }
示例#8
0
        public void Runner_should_capture_details_about_sub_step_initialization_failure()
        {
            Assert.Throws <InvalidOperationException>(() => _runner.Test().TestGroupScenario(Incorrect_step_group));
            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps().ToArray();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 1, "Incorrect step group", ExecutionStatus.Failed, "Step 1: Sub-steps initialization failed: abc"));
        }
示例#9
0
        public void Should_capture_method_call()
        {
            _subject.RunScenario(call => Product_is_available_in_product_storage(GetType().ToString()));

            var result = _subject.Result.Scenarios.Single();

            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, string.Format("CALL Product \"{0}\" is available in product storage", GetType()), ResultStatus.Passed)
            });
        }
示例#10
0
        public void Should_capture_local_variable()
        {
            string name = GetType().Name;

            _subject.RunScenario(call => Product_is_available_in_product_storage(name));

            var result = _subject.Result.Scenarios.Single();

            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, string.Format("CALL Product \"{0}\" is available in product storage", name), ResultStatus.Passed)
            });
        }
示例#11
0
        public void It_should_collect_scenario_result_via_fluent_interfaces()
        {
            _subject.NewScenario().Run(Step_one, Step_two);

            var result = _subject.Result.Scenarios.Single();

            Assert.That(result.Name, Is.EqualTo("It should collect scenario result via fluent interfaces"));
            Assert.That(result.Status, Is.EqualTo(ResultStatus.Passed));
            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "Step one", ResultStatus.Passed),
                new StepResultExpectation(2, "Step two", ResultStatus.Passed)
            });
        }
示例#12
0
        public void Runner_should_execute_all_steps_within_group()
        {
            Assert.DoesNotThrow(() => _runner.Test().TestGroupScenario(Passing_step_group));
            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps().ToArray();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 1, "Passing step group", ExecutionStatus.Passed));

            StepResultExpectation.AssertEqual(steps[0].GetSubSteps(),
                                              new StepResultExpectation("1.", 1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation("1.", 2, 3, "WHEN step two", ExecutionStatus.Passed),
                                              new StepResultExpectation("1.", 3, 3, "THEN step three", ExecutionStatus.Passed)
                                              );
        }
示例#13
0
        public void It_should_collect_scenario_result()
        {
            _subject.RunScenario(Step_one, Step_two);
            var result = _subject.Result.Scenarios.Single();

            Assert.That(result.Name, Is.EqualTo("It should collect scenario result"));
            Assert.That(result.Status, Is.EqualTo(ResultStatus.Passed));
            Assert.That(result.Categories, Is.Empty);

            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "Step one", ResultStatus.Passed),
                new StepResultExpectation(2, "Step two", ResultStatus.Passed)
            });
        }
示例#14
0
        public void Runner_should_mark_step_ignored_if_substep_is_ignored()
        {
            Assert.Throws <CustomIgnoreException>(() => _runner.Test().TestGroupScenario(Ignored_step_group));

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

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 1, "Ignored step group", ExecutionStatus.Ignored, $"Step 1.2: {IgnoreReason}"));

            StepResultExpectation.AssertEqual(steps[0].GetSubSteps(),
                                              new StepResultExpectation("1.", 1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation("1.", 2, 3, "WHEN step two ignoring scenario", ExecutionStatus.Ignored, $"Step 1.2: {IgnoreReason}"),
                                              new StepResultExpectation("1.", 3, 3, "THEN step three", ExecutionStatus.NotRun)
                                              );
        }
示例#15
0
        public void Runner_should_mark_step_failed_if_substep_fails()
        {
            Assert.Throws <InvalidOperationException>(() => _runner.Test().TestGroupScenario(Failing_step_group));

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

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 1, "Failing step group", ExecutionStatus.Failed, $"Step 1.2: {ExceptionReason}"));

            StepResultExpectation.AssertEqual(steps[0].GetSubSteps(),
                                              new StepResultExpectation("1.", 1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation("1.", 2, 3, "WHEN step two throwing exception", ExecutionStatus.Failed, $"Step 1.2: {ExceptionReason}"),
                                              new StepResultExpectation("1.", 3, 3, "THEN step three", ExecutionStatus.NotRun)
                                              );
        }
示例#16
0
        public void Runner_should_mark_step_bypassed_if_substep_is_bypassed()
        {
            Assert.DoesNotThrow(() => _runner.Test().TestGroupScenario(Bypassed_step_group));

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

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 1, "Bypassed step group", ExecutionStatus.Bypassed, $"Step 1.2: {BypassReason}"));

            StepResultExpectation.AssertEqual(steps[0].GetSubSteps(),
                                              new StepResultExpectation("1.", 1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation("1.", 2, 3, "WHEN step two is bypassed", ExecutionStatus.Bypassed, $"Step 1.2: {BypassReason}"),
                                              new StepResultExpectation("1.", 3, 3, "THEN step three", ExecutionStatus.Passed)
                                              );
        }
示例#17
0
        public void It_should_capture_steps_with_parameters()
        {
            _runner.Test().TestScenario(
                TestStep.CreateAsync(Given_step_with_parameter, () => "abc"),
                TestStep.CreateAsync(When_step_with_parameter, () => 1),
                TestStep.CreateAsync(Then_step_with_parameter, () => 3.14));

            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 3, "GIVEN step with parameter \"abc\"", ExecutionStatus.Passed),
                                              new StepResultExpectation(2, 3, "WHEN step with parameter \"1\"", ExecutionStatus.Passed),
                                              new StepResultExpectation(3, 3, "THEN step with parameter \"3.14\"", ExecutionStatus.Passed)
                                              );
        }
示例#18
0
        public void It_should_capture_steps_with_parameters_inserted_in_proper_places()
        {
            _runner.Test().TestScenario(
                TestStep.CreateAsync(Method_with_replaced_parameter_PARAM_in_name, "abc"),
                TestStep.CreateAsync(Method_with_inserted_parameter_param_in_name, "abc"),
                TestStep.CreateAsync(Method_with_appended_parameter_at_the_end_of_name, "abc"));

            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 3, "Method with replaced parameter \"abc\" in name", ExecutionStatus.Passed),
                                              new StepResultExpectation(2, 3, "Method with inserted parameter param \"abc\" in name", ExecutionStatus.Passed),
                                              new StepResultExpectation(3, 3, "Method with appended parameter at the end of name [param: \"abc\"]", ExecutionStatus.Passed)
                                              );
        }
示例#19
0
        public void It_should_capture_bypassed_steps()
        {
            _runner.Test().TestScenario(
                Given_step_one,
                When_step_two_is_bypassed,
                Then_step_three);

            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation(2, 3, "WHEN step two is bypassed", ExecutionStatus.Bypassed, $"Step 2: {BypassReason}"),
                                              new StepResultExpectation(3, 3, "THEN step three", ExecutionStatus.Passed)
                                              );
        }
示例#20
0
        public void It_should_collect_results_for_scenarios_causing_formatting_failures()
        {
            var expectedErrorMessage = "Unable to format 'param' parameter of step '1/1 Method with wrong formatter param \"<?>\"': Input string was not in a correct format.";

            var ex = Assert.Throws <InvalidOperationException>(() => _runner.Test().TestScenario(TestStep.CreateAsync(Method_with_wrong_formatter_param, () => "abc")));

            Assert.That(ex.Message, Is.EqualTo(expectedErrorMessage));

            var result = _feature.GetFeatureResult().GetScenarios().Single();

            Assert.That(result.Status, Is.EqualTo(ExecutionStatus.Failed));
            Assert.That(result.StatusDetails, Is.EqualTo("Step 1: " + expectedErrorMessage));

            StepResultExpectation.AssertEqual(result.GetSteps(),
                                              new StepResultExpectation(1, 1, "Method with wrong formatter param \"<?>\"", ExecutionStatus.Failed, expectedErrorMessage));
        }
示例#21
0
        public void Should_collect_scenario_result_with_steps_parameters_inserted_in_proper_places()
        {
            _subject.RunScenario(
                replace => Method_with_parameters_where_param_has_PARAM_value("abc"),
                insert => Method_with_parameters_where_param_is_first_param_on_list("abc_123"),
                others => Method_with_parameters_where_param_is_VALUE("abc", 5, "other param"));

            var result = _subject.Result.Scenarios.Single();

            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "REPLACE Method with parameters where param has \"abc\" value", ResultStatus.Passed),
                new StepResultExpectation(2, "INSERT Method with parameters where param \"abc_123\" is first param on list", ResultStatus.Passed),
                new StepResultExpectation(3, "OTHERS Method with parameters where param \"abc\" is \"5\" [lastParam: \"other param\"]", ResultStatus.Passed)
            });
        }
示例#22
0
        public void Invalid_step_descriptors_should_make_scenario_failing_immediately_without_execution()
        {
            var step1 = TestStep.Create(Step_that_should_not_run);
            var step2 = StepDescriptor.CreateInvalid(new Exception("reason1"));
            var step3 = StepDescriptor.CreateInvalid(new Exception("reason2"));
            var ex    = Assert.Throws <AggregateException>(() => _runner.Test().TestScenario(step1, step2, step3));

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

            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 3, "Step that should not run", ExecutionStatus.NotRun),
                                              new StepResultExpectation(2, 3, "<INVALID STEP>", ExecutionStatus.Failed, "Step 2: reason1"),
                                              new StepResultExpectation(3, 3, "<INVALID STEP>", ExecutionStatus.Failed, "Step 3: reason2"));
        }
示例#23
0
        public void It_should_collect_scenario_result_for_explicitly_named_scenario()
        {
            const string scenarioName = "my scenario";

#pragma warning disable 0618
            _subject.RunScenario(scenarioName, Step_one, Step_two);
#pragma warning restore 0618
            var result = _subject.Result.Scenarios.Single();
            Assert.That(result.Name, Is.EqualTo(scenarioName));
            Assert.That(result.Label, Is.Null);
            Assert.That(result.Status, Is.EqualTo(ResultStatus.Passed));
            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "Step one", ResultStatus.Passed),
                new StepResultExpectation(2, "Step two", ResultStatus.Passed)
            });
        }
        public void Should_collect_results_for_scenario_with_shared_context()
        {
            _subject.RunScenario <CustomContext>(
                Given_shared_value_is_5,
                Then_shared_value_is_passed_to_second_step_and_still_match_5);

            var result = _subject.Result.Scenarios.Single();

            Assert.That(result.Name, Is.EqualTo("Should collect results for scenario with shared context"));
            Assert.That(result.Label, Is.EqualTo("Label-12"));
            Assert.That(result.Status, Is.EqualTo(ResultStatus.Passed));
            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "GIVEN shared value is 5", ResultStatus.Passed),
                new StepResultExpectation(2, "THEN shared value is passed to second step and still match 5", ResultStatus.Passed)
            });
        }
        public void Should_collect_results_for_scenario_with_shared_context_passed_explicitly()
        {
            _subject.RunScenario(new CustomContext {
                Shared = 3
            },
                                 Step_checking_shared_value_eq_3);

            var result = _subject.Result.Scenarios.Single();

            Assert.That(result.Name, Is.EqualTo("Should collect results for scenario with shared context passed explicitly"));
            Assert.That(result.Label, Is.EqualTo("Label-1"));
            Assert.That(result.Status, Is.EqualTo(ResultStatus.Passed));
            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "Step checking shared value eq 3", ResultStatus.Passed)
            });
        }
示例#26
0
        public void It_should_capture_step_status_with_custom_exception_mapping()
        {
            var feature = TestableFeatureRunnerRepository.GetRunner(GetType());
            var runner  = feature.GetBddRunner(this);

            Assert.Throws <CustomIgnoreException>(() => runner.Test().TestScenario(
                                                      Given_step_one,
                                                      When_step_two_ignoring_scenario,
                                                      Then_step_three));

            var steps = feature.GetFeatureResult().GetScenarios().Single().GetSteps();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation(2, 3, "WHEN step two ignoring scenario", ExecutionStatus.Ignored, $"Step 2: {IgnoreReason}"),
                                              new StepResultExpectation(3, 3, "THEN step three", ExecutionStatus.NotRun));
        }
示例#27
0
        public void Should_allow_to_reuse_existing_steps_with_action_type()
        {
            _subject.RunScenario(
                _ => Given_product_is_available_in_product_storage("wooden desk"),
                _ => When_customer_orders_this_product(),
                _ => Then_customer_receives_invoice_for_product_in_amount_pounds("wooden desk", 62),
                _ => Then_product_is_sent_to_customer());

            var result = _subject.Result.Scenarios.Single();

            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "GIVEN product \"wooden desk\" is available in product storage", ResultStatus.Passed),
                new StepResultExpectation(2, "WHEN customer orders this product", ResultStatus.Passed),
                new StepResultExpectation(3, "THEN customer receives invoice for product \"wooden desk\" in amount \"62\" pounds", ResultStatus.Passed),
                new StepResultExpectation(4, "AND product is sent to customer", ResultStatus.Passed)
            });
        }
示例#28
0
        public void Should_capture_parameters_formatted_with_invariant_culture()
        {
            _subject.RunScenario(
                call => Method_with_parameter(1234234),
                call => Method_with_parameter(3.53),
                call => Method_with_parameter(22.67m),
                call => Method_with_parameter(new DateTime(2014, 05, 31, 17, 31, 27)));

            var result = _subject.Result.Scenarios.Single();

            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "CALL Method with parameter \"1234234\"", ResultStatus.Passed),
                new StepResultExpectation(2, "CALL Method with parameter \"3.53\"", ResultStatus.Passed),
                new StepResultExpectation(3, "CALL Method with parameter \"22.67\"", ResultStatus.Passed),
                new StepResultExpectation(4, "CALL Method with parameter \"05/31/2014 17:31:27\"", ResultStatus.Passed)
            });
        }
示例#29
0
        public void Should_capture_parameters_just_before_call_and_evaluate_them_once()
        {
            int x = 0;

            _subject.RunScenario(
                then => Values_equal(1, Add(ref x)),
                then => Values_equal(2, Add(ref x)),
                then => Values_equal(3, Add(ref x)));

            var result = _subject.Result.Scenarios.Single();

            StepResultExpectation.Assert(result.Steps, new[]
            {
                new StepResultExpectation(1, "THEN Values equal [expected: \"1\"] [actual: \"1\"]", ResultStatus.Passed),
                new StepResultExpectation(2, "THEN Values equal [expected: \"2\"] [actual: \"2\"]", ResultStatus.Passed),
                new StepResultExpectation(3, "THEN Values equal [expected: \"3\"] [actual: \"3\"]", ResultStatus.Passed)
            });
        }
示例#30
0
        public void It_should_capture_failed_steps()
        {
            try
            {
                _runner.Test().TestScenario(
                    Given_step_one,
                    When_step_two_throwing_exception,
                    Then_step_three);
            }
            catch { }

            var steps = _feature.GetFeatureResult().GetScenarios().Single().GetSteps();

            StepResultExpectation.AssertEqual(steps,
                                              new StepResultExpectation(1, 3, "GIVEN step one", ExecutionStatus.Passed),
                                              new StepResultExpectation(2, 3, "WHEN step two throwing exception", ExecutionStatus.Failed, $"Step 2: {ExceptionReason}"),
                                              new StepResultExpectation(3, 3, "THEN step three", ExecutionStatus.NotRun)
                                              );
        }