Search in sources :

Example 26 with RunNotifier

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)")));
    }
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) InOrder(org.mockito.InOrder) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.jupiter.api.Test)

Example 27 with RunNotifier

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"));
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Test(org.junit.jupiter.api.Test)

Example 28 with RunNotifier

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)")));
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) InOrder(org.mockito.InOrder) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 29 with RunNotifier

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")));
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) InOrder(org.mockito.InOrder) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 30 with RunNotifier

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;
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier)

Aggregations

RunNotifier (org.junit.runner.notification.RunNotifier)53 Failure (org.junit.runner.notification.Failure)16 Description (org.junit.runner.Description)15 Test (org.junit.Test)14 RunListener (org.junit.runner.notification.RunListener)13 Test (org.junit.jupiter.api.Test)9 Runner (org.junit.runner.Runner)9 InOrder (org.mockito.InOrder)7 Feature (io.cucumber.core.gherkin.Feature)5 ArrayList (java.util.ArrayList)5 Before (org.junit.Before)5 Request (org.junit.runner.Request)5 Result (org.junit.runner.Result)5 ParentRunner (org.junit.runners.ParentRunner)4 HashMap (java.util.HashMap)3 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)3 BlockJUnit4ClassRunner (org.junit.runners.BlockJUnit4ClassRunner)3 KieSession (org.kie.api.runtime.KieSession)3 Match (gherkin.formatter.model.Match)2 Scenario (gherkin.formatter.model.Scenario)2