use of org.junit.runner.notification.RunNotifier in project cucumber-jvm by cucumber.
the class CucumberTest method cucumber_distinguishes_between_identical_features.
@Test
void cucumber_distinguishes_between_identical_features() throws Exception {
RunNotifier notifier = new RunNotifier();
RunListener listener = Mockito.mock(RunListener.class);
notifier.addListener(listener);
Request.classes(ValidEmpty.class).getRunner().run(notifier);
{
InOrder order = Mockito.inOrder(listener);
order.verify(listener).testStarted(argThat(new DescriptionMatcher("A single scenario(A feature with a single scenario #1)")));
order.verify(listener).testFinished(argThat(new DescriptionMatcher("A single scenario(A feature with a single scenario #1)")));
order.verify(listener).testStarted(argThat(new DescriptionMatcher("A single scenario(A feature with a single scenario #2)")));
order.verify(listener).testFinished(argThat(new DescriptionMatcher("A single scenario(A feature with a single scenario #2)")));
}
}
use of org.junit.runner.notification.RunNotifier in project cucumber-jvm by cucumber.
the class InvokeMethodsAroundEventsTest method invoke_methods_around_events.
@Test
void invoke_methods_around_events() throws InitializationError {
Cucumber cucumber = new Cucumber(BeforeAfterClass.class);
cucumber.run(new RunNotifier());
assertThat(events, contains("BeforeClass", "TestRunStarted", "BeforeAll", "TestSourceRead", "TestCaseStarted", "Before", "Step", "Step", "Step", "After", "TestCaseFinished", "TestCaseStarted", "Before", "Step", "Step", "Step", "After", "TestCaseFinished", "TestSourceRead", "TestCaseStarted", "Before", "Step", "Step", "Step", "After", "TestCaseFinished", "AfterAll", "TestRunFinished", "AfterClass"));
}
use of org.junit.runner.notification.RunNotifier in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_not_issue_notification_for_steps_by_default_scenario_outline_with_two_examples_table_and_background.
@Test
void should_not_issue_notification_for_steps_by_default_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");
RunNotifier notifier = runFeatureWithNotifier(feature, new JUnitOptions());
InOrder order = inOrder(notifier);
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("scenario #1(feature name)")));
order.verify(notifier, times(1)).fireTestFailure(argThat(new FailureMatcher("scenario #1(feature name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario #1(feature name)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("scenario #2(feature name)")));
order.verify(notifier, times(1)).fireTestFailure(argThat(new FailureMatcher("scenario #2(feature name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario #2(feature name)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("scenario #3(feature name)")));
order.verify(notifier, times(1)).fireTestFailure(argThat(new FailureMatcher("scenario #3(feature name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario #3(feature name)")));
}
use of org.junit.runner.notification.RunNotifier in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method step_notification_can_be_turned_on_two_scenarios_with_background.
@Test
void step_notification_can_be_turned_on_two_scenarios_with_background() {
Feature feature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Background: background\n" + " Given step #1\n" + " Scenario: scenario_1 name\n" + " When step #2\n" + " Then step #3\n" + " Scenario: scenario_2 name\n" + " Then another step #2\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 name")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #1(scenario_1 name)")));
order.verify(notifier).fireTestFailure(argThat(new FailureMatcher("step #1(scenario_1 name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #1(scenario_1 name)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #2(scenario_1 name)")));
order.verify(notifier).fireTestAssumptionFailed(argThat(new FailureMatcher("step #2(scenario_1 name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #2(scenario_1 name)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #3(scenario_1 name)")));
order.verify(notifier).fireTestAssumptionFailed(argThat(new FailureMatcher("step #3(scenario_1 name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #3(scenario_1 name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario_1 name")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("scenario_2 name")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("step #1(scenario_2 name)")));
order.verify(notifier).fireTestFailure(argThat(new FailureMatcher("step #1(scenario_2 name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("step #1(scenario_2 name)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("another step #2(scenario_2 name)")));
order.verify(notifier).fireTestAssumptionFailed(argThat(new FailureMatcher("another step #2(scenario_2 name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("another step #2(scenario_2 name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario_2 name")));
}
use of org.junit.runner.notification.RunNotifier in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method runFeatureWithNotifier.
private RunNotifier runFeatureWithNotifier(Feature feature, JUnitOptions options) {
FeatureRunner runner = createFeatureRunner(feature, options);
RunNotifier notifier = mock(RunNotifier.class);
runner.run(notifier);
return notifier;
}
Aggregations