public void It_should_notify_execution_progress_for_parameterized_steps() { var progressNotifier = new CapturingProgressNotifier(); var feature = new TestableFeatureRunnerRepository(progressNotifier, fixture => progressNotifier).GetRunnerFor(GetType()); var runner = feature.GetBddRunner(this); try { runner.Test().TestScenario( TestStep.CreateAsync(Given_step_with_parameter, () => "abc"), TestStep.CreateAsync(When_step_with_parameter, ThrowingParameterInvocation), TestStep.CreateAsync(Then_step_with_parameter, () => 2.22)); } catch { } feature.Dispose(); string[] expected = { "Feature Start: CoreBddRunner progress notification tests [label1, label2]: feature description", "Scenario Start: It should notify execution progress for parameterized steps [lab1, lab2] <category 1, category 2>", "Step Start: 1/3 GIVEN step with parameter \"abc\"", "Step Finish: 1/3 GIVEN step with parameter \"abc\" | Status:Passed | ExecutionTimePresent:True | Details:", "Scenario Finish: It should notify execution progress for parameterized steps [lab1, lab2] <category 1, category 2> | Status:Failed | ExecutionTimePresent:True | Steps:3 | Details:Step 2: parameter exception", "Feature Finish: CoreBddRunner progress notification tests [label1, label2]: feature description | Scenarios:1" }; Assert.That(progressNotifier.Notifications, Is.EqualTo(expected), "Expected:\r\n{0}\r\n\r\nGot:\r\n{1}\r\n\r\n", string.Join("\r\n", expected), string.Join("\r\n", progressNotifier.Notifications)); }
public void It_should_notify_execution_progress() { var progressNotifier = new CapturingProgressNotifier(); var feature = new TestableFeatureRunnerRepository(progressNotifier, fixture => progressNotifier).GetRunnerFor(GetType()); var runner = feature.GetBddRunner(this); try { runner.Test().TestScenario( Given_step_one, When_step_two_with_comment, Then_step_three_should_throw_exception); } catch { } feature.Dispose(); string[] expected = { "Feature Start: CoreBddRunner progress notification tests [label1, label2]: feature description", "Scenario Start: It should notify execution progress [lab1, lab2] <category 1, category 2>", "Step Start: 1/3 GIVEN step one", "Step Finish: 1/3 GIVEN step one | Status:Passed | ExecutionTimePresent:True | Details:", "Step Start: 2/3 WHEN step two with comment", "Step 2/3 Comment: some comment", "Step Finish: 2/3 WHEN step two with comment | Status:Passed | ExecutionTimePresent:True | Details:", "Step Start: 3/3 THEN step three should throw exception", "Step Finish: 3/3 THEN step three should throw exception | Status:Failed | ExecutionTimePresent:True | Details:Step 3: exception reason", "Scenario Finish: It should notify execution progress [lab1, lab2] <category 1, category 2> | Status:Failed | ExecutionTimePresent:True | Steps:3 | Details:Step 3: exception reason", "Feature Finish: CoreBddRunner progress notification tests [label1, label2]: feature description | Scenarios:1" }; Assert.That(progressNotifier.Notifications, Is.EqualTo(expected), "Expected:\r\n{0}\r\n\r\nGot:\r\n{1}\r\n\r\n", string.Join("\r\n", expected), string.Join("\r\n", progressNotifier.Notifications)); }
public void ScenarioExecutionContext_should_throw_if_not_installed() { var runner = TestableFeatureRunnerRepository.GetRunner(GetType()).GetBddRunner(this); var exception = Assert.ThrowsAsync <InvalidOperationException>(() => RunScenarioAsync(runner)); Assert.That(exception.Message, Is.EqualTo("Current task is not executing any scenarios or ScenarioExecutionContext is not enabled in LightBddConfiguration. Ensure that configuration.ExecutionExtensionsConfiguration().EnableScenarioExecutionContext() is called during LightBDD initialization and operation accessing ScenarioExecutionContext is called from task running scenario.")); }
public void It_should_collect_standard_feature_description_if_both_are_specified() { var feature = TestableFeatureRunnerRepository.GetRunner(typeof(Feature_with_two_descriptions)); var runner = feature.GetBddRunner(new Feature_with_two_descriptions()); runner.Test().TestScenario(Some_step); Assert.That(feature.GetFeatureResult().Info.Description, Is.EqualTo("standard description")); }
public void It_should_collect_custom_feature_description() { var feature = TestableFeatureRunnerRepository.GetRunner(GetType()); var runner = feature.GetBddRunner(this); runner.Test().TestScenario(Some_step); Assert.That(feature.GetFeatureResult().Info.Description, Is.EqualTo("some description")); }
public void It_should_collect_plain_feature() { var feature = TestableFeatureRunnerRepository.GetRunner(typeof(Feature_without_details)).GetFeatureResult(); Assert.That(feature.Info.Name.ToString(), Is.EqualTo("Feature without details")); Assert.Null(feature.Info.Description); Assert.That(feature.Info.Labels, Is.Empty); }
public void It_should_collect_feature_with_description() { var feature = TestableFeatureRunnerRepository.GetRunner(typeof(Feature_with_description)).GetFeatureResult(); Assert.That(feature.Info.Name.ToString(), Is.EqualTo("Feature with description")); Assert.That(feature.Info.Description, Is.EqualTo("Runner tests description")); Assert.That(feature.Info.Labels, Is.Empty); }
public void It_should_collect_feature_with_labels() { var feature = TestableFeatureRunnerRepository.GetRunner(typeof(Feature_with_labels)).GetFeatureResult(); Assert.That(feature.Info.Name.ToString(), Is.EqualTo("Feature with labels")); Assert.That(feature.Info.Labels, Is.EqualTo(new[] { "Ticket-1", "Ticket-2" })); Assert.Null(feature.Info.Description); }
public void It_should_collect_custom_categories() { var feature = TestableFeatureRunnerRepository.GetRunner(GetType()); var runner = feature.GetBddRunner(this); runner.Test().TestScenario(Some_step); var scenario = feature.GetFeatureResult().GetScenarios().Single(); Assert.That(scenario.Info.Categories, Is.EqualTo(new[] { "some global category", "some local category", "standard global category", "standard local category" })); }
public void It_should_notify_execution_progress_of_composite_steps() { var progressNotifier = new CapturingProgressNotifier(); var feature = new TestableFeatureRunnerRepository(progressNotifier, fixture => progressNotifier).GetRunnerFor(GetType()); var runner = feature.GetBddRunner(this); try { runner.Test().TestGroupScenario(Composite_group); } catch { } feature.Dispose(); string[] expected = { "Feature Start: CoreBddRunner progress notification tests [label1, label2]: feature description", "Scenario Start: It should notify execution progress of composite steps [lab1, lab2] <category 1, category 2>", "Step Start: 1/1 Composite group", "Step Start: 1.1/1.2 Passing step group with comment", "Step Start: 1.1.1/1.1.3 GIVEN step one", "Step Finish: 1.1.1/1.1.3 GIVEN step one | Status:Passed | ExecutionTimePresent:True | Details:", "Step Start: 1.1.2/1.1.3 WHEN step two with comment", "Step 1.1.2/1.1.3 Comment: some comment", "Step Finish: 1.1.2/1.1.3 WHEN step two with comment | Status:Passed | ExecutionTimePresent:True | Details:", "Step Start: 1.1.3/1.1.3 THEN step three", "Step Finish: 1.1.3/1.1.3 THEN step three | Status:Passed | ExecutionTimePresent:True | Details:", "Step Finish: 1.1/1.2 Passing step group with comment | Status:Passed | ExecutionTimePresent:True | Details:", "Step Start: 1.2/1.2 Bypassed step group", "Step Start: 1.2.1/1.2.3 GIVEN step one", "Step Finish: 1.2.1/1.2.3 GIVEN step one | Status:Passed | ExecutionTimePresent:True | Details:", "Step Start: 1.2.2/1.2.3 WHEN step two is bypassed", "Step Finish: 1.2.2/1.2.3 WHEN step two is bypassed | Status:Bypassed | ExecutionTimePresent:True | Details:Step 1.2.2: bypass reason", "Step Start: 1.2.3/1.2.3 THEN step three", "Step Finish: 1.2.3/1.2.3 THEN step three | Status:Passed | ExecutionTimePresent:True | Details:", "Step Finish: 1.2/1.2 Bypassed step group | Status:Bypassed | ExecutionTimePresent:True | Details:Step 1.2.2: bypass reason", "Step Finish: 1/1 Composite group | Status:Bypassed | ExecutionTimePresent:True | Details:Step 1.2.2: bypass reason", "Scenario Finish: It should notify execution progress of composite steps [lab1, lab2] <category 1, category 2> | Status:Bypassed | ExecutionTimePresent:True | Steps:1 | Details:Step 1.2.2: bypass reason", "Feature Finish: CoreBddRunner progress notification tests [label1, label2]: feature description | Scenarios:1" }; Assert.That(progressNotifier.Notifications, Is.EqualTo(expected), "Expected:\r\n{0}\r\n\r\nGot:\r\n{1}\r\n\r\n", string.Join("\r\n", expected), string.Join("\r\n", progressNotifier.Notifications)); }
public void Comment_should_throw_exception_if_feature_is_not_enabled() { var runner = new TestableFeatureRunnerRepository( TestableIntegrationContextBuilder.Default() .WithConfiguration(cfg => cfg.ExecutionExtensionsConfiguration().EnableScenarioExecutionContext()) ) .GetRunnerFor(GetType()) .GetBddRunner(this); var exception = Assert.Throws <InvalidOperationException>(() => runner.Test().TestScenario(TestStep.CreateAsync(Commented_step, "some comment"))); Assert.That(exception.Message, Is.EqualTo("Current task is not executing any scenario steps or commenting feature is not enabled in LightBddConfiguration. Ensure that configuration.ExecutionExtensionsConfiguration().EnableStepCommenting() is called during LightBDD initialization and commenting feature is called from task running scenario step.")); }
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)); }
public async Task It_should_parse_composite_names() { var featureRunner = TestableFeatureRunnerRepository.GetRunner(GetType()); var runner = featureRunner.GetBddRunner(this); var expectedValue = "Some\r\nmultiline\tresponse"; await runner .AddStep("Given my scenario with value [55]", _ => { }) .AddStep(" When I send My_Request<int> for it ", _ => { }) .AddAsyncStep($"Only then I should receive \"{expectedValue}\"", _ => Task.CompletedTask) .RunAsync(); var steps = featureRunner.GetFeatureResult().GetScenarios().Single().GetSteps(); StepResultExpectation.AssertEqual(steps, new StepResultExpectation(1, 3, "GIVEN my scenario with value [55]", ExecutionStatus.Passed), new StepResultExpectation(2, 3, "WHEN I send My_Request<int> for it", ExecutionStatus.Passed), new StepResultExpectation(3, 3, "Only then I should receive \"Some multiline response\"", ExecutionStatus.Passed)); }
public void It_should_instantiate_new_scenario_progress_notifier_for_each_scenario() { var notifiers = new List <CapturingProgressNotifier>(); Func <object, IScenarioProgressNotifier> captureNotifierCreation = fixture => { var notifier = new CapturingProgressNotifier(); notifiers.Add(notifier); return(notifier); }; var runner = new TestableFeatureRunnerRepository(NoProgressNotifier.Default, captureNotifierCreation).GetRunnerFor(GetType()).GetBddRunner(this); runner.Test().TestNamedScenario("scenario1", TestStep.CreateSync(Given_step_one)); runner.Test().TestNamedScenario("scenario2", TestStep.CreateSync(Given_step_one)); runner.Test().TestNamedScenario("scenario3", TestStep.CreateSync(Given_step_one)); Assert.That(notifiers.Count, Is.EqualTo(3)); Assert.That(notifiers[0].Notifications.Count(n => n.StartsWith("Scenario Start: scenario1")), Is.EqualTo(1), "scenario1"); Assert.That(notifiers[1].Notifications.Count(n => n.StartsWith("Scenario Start: scenario2")), Is.EqualTo(1), "scenario2"); Assert.That(notifiers[2].Notifications.Count(n => n.StartsWith("Scenario Start: scenario3")), Is.EqualTo(1), "scenario3"); }
public void Only_one_repository_should_be_created_per_type() { var taskCount = 20; var mockNotifier = new Mock <IFeatureProgressNotifier>(); mockNotifier.Setup(x => x.NotifyFeatureStart(It.IsAny <IFeatureInfo>())).Callback(() => Thread.Sleep(100)); var testableIntegrationContextBuilder = TestableIntegrationContextBuilder.Default().WithFeatureProgressNotifier(mockNotifier.Object); var runners = new ConcurrentQueue <IFeatureRunner>(); var repository = new TestableFeatureRunnerRepository(testableIntegrationContextBuilder); using (var barrier = new Barrier(taskCount)) { void GetRunner() { barrier.SignalAndWait(); runners.Enqueue(repository.GetRunnerFor(GetType())); } var threads = Enumerable.Range(0, taskCount) .Select(_ => new Thread(GetRunner)) .ToArray(); foreach (var thread in threads) { thread.Start(); } foreach (var thread in threads) { thread.Join(); } } Assert.That(runners.Distinct().Count(), Is.EqualTo(1)); mockNotifier.Verify(x => x.NotifyFeatureStart(It.IsAny <IFeatureInfo>()), Times.Once); }
public void SetUp() { _runner = TestableFeatureRunnerRepository.GetRunner(GetType()).GetBddRunner(this); _executedSteps = new List <Tuple <string, object> >(); }
public void It_should_wire_steps_scenario_and_feature_infos() { IFeatureInfo featureInfo = null; IFeatureResult featureResult = null; IScenarioInfo scenarioInfo = null; IScenarioResult scenarioResult = null; var stepInfos = new List <IStepInfo>(); var stepResults = new List <IStepResult>(); var featureNotifier = new Mock <IFeatureProgressNotifier>(); var scenarioNotifier = new Mock <IScenarioProgressNotifier>(); featureNotifier.Setup(x => x.NotifyFeatureStart(It.IsAny <IFeatureInfo>())) .Callback((IFeatureInfo x) => featureInfo = x); featureNotifier.Setup(x => x.NotifyFeatureFinished(It.IsAny <IFeatureResult>())) .Callback((IFeatureResult x) => featureResult = x); scenarioNotifier.Setup(x => x.NotifyScenarioStart(It.IsAny <IScenarioInfo>())) .Callback((IScenarioInfo x) => scenarioInfo = x); scenarioNotifier.Setup(x => x.NotifyScenarioFinished(It.IsAny <IScenarioResult>())) .Callback((IScenarioResult x) => scenarioResult = x); scenarioNotifier.Setup(x => x.NotifyStepStart(It.IsAny <IStepInfo>())) .Callback((IStepInfo x) => stepInfos.Add(x)); scenarioNotifier.Setup(x => x.NotifyStepFinished(It.IsAny <IStepResult>())) .Callback((IStepResult x) => stepResults.Add(x)); var feature = new TestableFeatureRunnerRepository(featureNotifier.Object, fixture => scenarioNotifier.Object) .GetRunnerFor(GetType()); var runner = feature.GetBddRunner(this); try { runner.Test().TestGroupScenario(Composite_group); } catch { } feature.Dispose(); Assert.That(featureInfo, Is.Not.Null); Assert.That(featureInfo.RuntimeId, Is.Not.EqualTo(Guid.Empty), "Feature should have unique RuntimeId"); Assert.That(featureResult.Info, Is.SameAs(featureInfo)); Assert.That(scenarioInfo, Is.Not.Null); Assert.That(scenarioInfo.RuntimeId, Is.Not.EqualTo(Guid.Empty), "Scenario should have unique RuntimeId"); Assert.That(scenarioResult.Info, Is.SameAs(scenarioInfo)); Assert.That(scenarioInfo.Parent, Is.SameAs(featureInfo)); Assert.That(stepInfos.Select(x => x.RuntimeId).Distinct().Count(), Is.EqualTo(9), "Each step should have unique RuntimeId"); Assert.That(stepInfos[0].Parent, Is.SameAs(scenarioInfo)); Assert.That(stepInfos[1].Parent, Is.SameAs(stepInfos[0])); Assert.That(stepInfos[2].Parent, Is.SameAs(stepInfos[1])); Assert.That(stepInfos[3].Parent, Is.SameAs(stepInfos[1])); Assert.That(stepInfos[4].Parent, Is.SameAs(stepInfos[1])); Assert.That(stepInfos[5].Parent, Is.SameAs(stepInfos[0])); Assert.That(stepInfos[6].Parent, Is.SameAs(stepInfos[5])); Assert.That(stepInfos[7].Parent, Is.SameAs(stepInfos[5])); Assert.That(stepInfos[8].Parent, Is.SameAs(stepInfos[5])); Assert.That(stepResults[0].Info, Is.SameAs(stepInfos[2]), "1.1.1"); Assert.That(stepResults[1].Info, Is.SameAs(stepInfos[3]), "1.1.2"); Assert.That(stepResults[2].Info, Is.SameAs(stepInfos[4]), "1.1.3"); Assert.That(stepResults[3].Info, Is.SameAs(stepInfos[1]), "1.1"); Assert.That(stepResults[4].Info, Is.SameAs(stepInfos[6]), "1.2.1"); Assert.That(stepResults[5].Info, Is.SameAs(stepInfos[7]), "1.2.2"); Assert.That(stepResults[6].Info, Is.SameAs(stepInfos[8]), "1.2.3"); Assert.That(stepResults[7].Info, Is.SameAs(stepInfos[5]), "1.2"); Assert.That(stepResults[8].Info, Is.SameAs(stepInfos[0]), "1"); }
public void It_should_not_allow_to_run_scenarios_without_name(string name) { var exception = Assert.Throws <ArgumentException>(() => TestableFeatureRunnerRepository.GetRunner(GetType()).ForFixture(this).NewScenario().WithName(name)); Assert.That(exception.Message, Does.StartWith("Unable to create scenario without name")); }
public void SetUp() { _feature = TestableFeatureRunnerRepository.GetRunner(GetType()); _runner = _feature.GetBddRunner(this); }
public void SetUp() { _feature = TestableFeatureRunnerRepository.GetRunner(GetType()); _runner = _feature.GetBddRunner(this); _executedSteps = new List <string>(); }