use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_not_create_step_descriptions_by_default.
@Test
void should_not_create_step_descriptions_by_default() {
Feature cucumberFeature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Background:\n" + " Given background step\n" + " Scenario: A\n" + " Then scenario name\n" + " Scenario: B\n" + " Then scenario name\n" + " Scenario Outline: C\n" + " Then scenario <name>\n" + " Examples:\n" + " | name |\n" + " | C |\n" + " | D |\n" + " | E |\n");
FeatureRunner runner = createFeatureRunner(cucumberFeature, new JUnitOptions());
Description feature = runner.getDescription();
Description scenarioA = feature.getChildren().get(0);
assertTrue(scenarioA.getChildren().isEmpty());
Description scenarioB = feature.getChildren().get(1);
assertTrue(scenarioB.getChildren().isEmpty());
Description scenarioC0 = feature.getChildren().get(2);
assertTrue(scenarioC0.getChildren().isEmpty());
Description scenarioC1 = feature.getChildren().get(3);
assertTrue(scenarioC1.getChildren().isEmpty());
Description scenarioC2 = feature.getChildren().get(4);
assertTrue(scenarioC2.getChildren().isEmpty());
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method step_descriptions_can_be_turned_on.
@Test
void step_descriptions_can_be_turned_on() {
Feature cucumberFeature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Background:\n" + " Given background step\n" + " Scenario: A\n" + " Then scenario name\n" + " Scenario: B\n" + " Then scenario name\n" + " Scenario Outline: C\n" + " Then scenario <name>\n" + " Examples:\n" + " | name |\n" + " | C |\n" + " | D |\n" + " | E |\n");
JUnitOptions junitOption = new JUnitOptionsBuilder().setStepNotifications(true).build();
FeatureRunner runner = createFeatureRunner(cucumberFeature, junitOption);
Description feature = runner.getDescription();
Description scenarioA = feature.getChildren().get(0);
assertThat(scenarioA.getChildren().size(), is(equalTo(2)));
Description scenarioB = feature.getChildren().get(1);
assertThat(scenarioB.getChildren().size(), is(equalTo(2)));
Description scenarioC0 = feature.getChildren().get(2);
assertThat(scenarioC0.getChildren().size(), is(equalTo(2)));
Description scenarioC1 = feature.getChildren().get(3);
assertThat(scenarioC1.getChildren().size(), is(equalTo(2)));
Description scenarioC2 = feature.getChildren().get(4);
assertThat(scenarioC2.getChildren().size(), is(equalTo(2)));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_populate_descriptions_with_stable_unique_ids.
@Test
void should_populate_descriptions_with_stable_unique_ids() {
Feature feature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Background:\n" + " Given background step\n" + " Scenario: A\n" + " Then scenario name\n" + " Scenario: B\n" + " Then scenario name\n" + " Scenario Outline: C\n" + " Then scenario <name>\n" + " Examples:\n" + " | name |\n" + " | C |\n" + " | D |\n" + " | E |\n");
FeatureRunner runner = createFeatureRunner(feature, new JUnitOptions());
FeatureRunner rerunner = createFeatureRunner(feature, new JUnitOptions());
Set<Description> descriptions = new HashSet<>();
assertDescriptionIsUnique(runner.getDescription(), descriptions);
assertDescriptionIsPredictable(runner.getDescription(), descriptions);
assertDescriptionIsPredictable(rerunner.getDescription(), descriptions);
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method step_notification_can_be_turned_on_scenario_outline_with_two_examples_table_and_background.
@Test
void step_notification_can_be_turned_on_scenario_outline_with_two_examples_table_and_background() {
Feature feature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Background: background\n" + " Given step #1\n" + " Scenario Outline: scenario <id>\n" + " When step #2 \n" + " Then step #3 \n" + " Examples: examples 1 name\n" + " | id | \n" + " | #1 |\n" + " | #2 |\n" + " Examples: examples 2 name\n" + " | id |\n" + " | #3 |\n");
JUnitOptions junitOption = new JUnitOptionsBuilder().setStepNotifications(true).build();
RunNotifier notifier = runFeatureWithNotifier(feature, junitOption);
InOrder order = inOrder(notifier);
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("scenario #1")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #1(scenario #1)")));
order.verify(notifier).fireTestFailure(argThat(new FailureMatcher("step #1(scenario #1)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #1(scenario #1)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #2(scenario #1)")));
order.verify(notifier).fireTestAssumptionFailed(argThat(new FailureMatcher("step #2(scenario #1)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #2(scenario #1)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #3(scenario #1)")));
order.verify(notifier).fireTestAssumptionFailed(argThat(new FailureMatcher("step #3(scenario #1)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #3(scenario #1)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario #1")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("scenario #2")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #1(scenario #2)")));
order.verify(notifier).fireTestFailure(argThat(new FailureMatcher("step #1(scenario #2)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #1(scenario #2)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #2(scenario #2)")));
order.verify(notifier).fireTestAssumptionFailed(argThat(new FailureMatcher("step #2(scenario #2)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #2(scenario #2)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #3(scenario #2)")));
order.verify(notifier).fireTestAssumptionFailed(argThat(new FailureMatcher("step #3(scenario #2)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #3(scenario #2)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario #2")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("scenario #3")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #1(scenario #3)")));
order.verify(notifier).fireTestFailure(argThat(new FailureMatcher("step #1(scenario #3)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #1(scenario #3)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #2(scenario #3)")));
order.verify(notifier).fireTestAssumptionFailed(argThat(new FailureMatcher("step #2(scenario #3)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #2(scenario #3)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #3(scenario #3)")));
order.verify(notifier).fireTestAssumptionFailed(argThat(new FailureMatcher("step #3(scenario #3)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #3(scenario #3)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario #3")));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_notify_of_failure_to_create_runners_and_request_test_execution_to_stop.
@Test
void should_notify_of_failure_to_create_runners_and_request_test_execution_to_stop() {
Feature feature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario_1 name\n" + " Given step #1\n");
Filters filters = new Filters(RuntimeOptions.defaultOptions());
IllegalStateException illegalStateException = new IllegalStateException();
RunnerSupplier runnerSupplier = () -> {
throw illegalStateException;
};
TimeServiceEventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
RuntimeOptions options = RuntimeOptions.defaultOptions();
CucumberExecutionContext context = new CucumberExecutionContext(bus, new ExitStatus(options), runnerSupplier);
FeatureRunner featureRunner = FeatureRunner.create(feature, null, filters, context, new JUnitOptions());
RunNotifier notifier = mock(RunNotifier.class);
PickleRunners.PickleRunner pickleRunner = featureRunner.getChildren().get(0);
featureRunner.runChild(pickleRunner, notifier);
Description description = pickleRunner.getDescription();
ArgumentCaptor<Failure> failureArgumentCaptor = ArgumentCaptor.forClass(Failure.class);
InOrder order = inOrder(notifier);
order.verify(notifier).fireTestStarted(description);
order.verify(notifier).fireTestFailure(failureArgumentCaptor.capture());
assertThat(failureArgumentCaptor.getValue().getException(), is(equalTo(illegalStateException)));
assertThat(failureArgumentCaptor.getValue().getDescription(), is(equalTo(description)));
order.verify(notifier).pleaseStop();
order.verify(notifier).fireTestFinished(description);
}
Aggregations