Search in sources :

Example 11 with TestStepStarted

use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.

the class JUnitReporterWithStepNotificationsTest method test_step_undefined_fires_test_failure_and_test_finished_for_undefined_step.

@Test
void test_step_undefined_fires_test_failure_and_test_finished_for_undefined_step() {
    jUnitReporter.startExecutionUnit(pickleRunner, runNotifier);
    Suggestion suggestion = new Suggestion("step name", singletonList("some snippet"));
    bus.send(new SnippetsSuggestedEvent(now(), featureUri, scenarioLine, scenarioLine, suggestion));
    bus.send(new TestCaseStarted(now(), testCase));
    bus.send(new TestStepStarted(now(), testCase, mockTestStep(step)));
    Throwable exception = new CucumberException("No step definitions found");
    Result result = new Result(Status.UNDEFINED, ZERO, exception);
    bus.send(new TestStepFinished(now(), testCase, mockTestStep(step), result));
    verify(runNotifier).fireTestFailure(failureArgumentCaptor.capture());
    verify(runNotifier).fireTestFinished(pickleRunner.describeChild(step));
    Failure stepFailure = failureArgumentCaptor.getValue();
    assertThat(stepFailure.getDescription(), is(equalTo(pickleRunner.describeChild(step))));
    assertThat(stepFailure.getException(), is(equalTo(exception)));
    bus.send(new TestCaseFinished(now(), testCase, result));
    verify(runNotifier, times(2)).fireTestFailure(failureArgumentCaptor.capture());
    verify(runNotifier).fireTestFinished(pickleRunner.describeChild(step));
    Failure pickleFailure = failureArgumentCaptor.getValue();
    assertThat(pickleFailure.getDescription(), is(equalTo(pickleRunner.getDescription())));
    assertThat(pickleFailure.getException().getMessage(), is("" + "The step 'step name' is undefined.\n" + "You can implement this step using the snippet(s) below:\n" + "\n" + "some snippet\n"));
}
Also used : Suggestion(io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion) TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) SnippetsSuggestedEvent(io.cucumber.plugin.event.SnippetsSuggestedEvent) CucumberException(io.cucumber.core.exception.CucumberException) TestStepStarted(io.cucumber.plugin.event.TestStepStarted) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) Failure(org.junit.runner.notification.Failure) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 12 with TestStepStarted

use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.

the class JUnitReporterWithStepNotificationsTest method test_step_finished_fires_test_failure_and_test_finished_for_skipped_step_with_pending_exception.

@Test
void test_step_finished_fires_test_failure_and_test_finished_for_skipped_step_with_pending_exception() {
    jUnitReporter.startExecutionUnit(pickleRunner, runNotifier);
    bus.send(new TestCaseStarted(now(), testCase));
    bus.send(new TestStepStarted(now(), testCase, mockTestStep(step)));
    Throwable exception = new TestPendingException("Oops");
    Result result = new Result(Status.PENDING, ZERO, exception);
    bus.send(new TestStepFinished(now(), testCase, mockTestStep(step), result));
    verify(runNotifier).fireTestFailure(failureArgumentCaptor.capture());
    verify(runNotifier).fireTestFinished(pickleRunner.describeChild(step));
    Failure stepFailure = failureArgumentCaptor.getValue();
    assertThat(stepFailure.getDescription(), is(equalTo(pickleRunner.describeChild(step))));
    assertThat(stepFailure.getException(), is(equalTo(exception)));
    bus.send(new TestCaseFinished(now(), testCase, result));
    verify(runNotifier, times(2)).fireTestFailure(failureArgumentCaptor.capture());
    verify(runNotifier).fireTestFinished(pickleRunner.describeChild(step));
    Failure pickleFailure = failureArgumentCaptor.getValue();
    assertThat(pickleFailure.getDescription(), is(equalTo(pickleRunner.getDescription())));
    assertThat(pickleFailure.getException(), is(equalTo(exception)));
}
Also used : TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) TestStepStarted(io.cucumber.plugin.event.TestStepStarted) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) Failure(org.junit.runner.notification.Failure) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 13 with TestStepStarted

use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.

the class JUnitReporterWithStepNotificationsTest method test_step_finished_fires_test_failure_and_test_finished_for_failed_step.

@Test
void test_step_finished_fires_test_failure_and_test_finished_for_failed_step() {
    jUnitReporter.startExecutionUnit(pickleRunner, runNotifier);
    bus.send(new TestCaseStarted(now(), testCase));
    bus.send(new TestStepStarted(now(), testCase, mockTestStep(step)));
    Throwable exception = new Exception("Oops");
    Result result = new Result(Status.FAILED, ZERO, exception);
    bus.send(new TestStepFinished(now(), testCase, mockTestStep(step), result));
    verify(runNotifier).fireTestFailure(failureArgumentCaptor.capture());
    verify(runNotifier).fireTestFinished(pickleRunner.describeChild(step));
    Failure stepFailure = failureArgumentCaptor.getValue();
    assertThat(stepFailure.getDescription(), is(equalTo(pickleRunner.describeChild(step))));
    assertThat(stepFailure.getException(), is(equalTo(exception)));
    bus.send(new TestCaseFinished(now(), testCase, result));
    verify(runNotifier, times(2)).fireTestFailure(failureArgumentCaptor.capture());
    verify(runNotifier).fireTestFinished(pickleRunner.describeChild(step));
    Failure pickleFailure = failureArgumentCaptor.getValue();
    assertThat(pickleFailure.getDescription(), is(equalTo(pickleRunner.getDescription())));
    assertThat(pickleFailure.getException(), is(equalTo(exception)));
}
Also used : TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) TestStepStarted(io.cucumber.plugin.event.TestStepStarted) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) MultipleFailureException(org.junit.runners.model.MultipleFailureException) AssumptionViolatedException(org.junit.AssumptionViolatedException) CucumberException(io.cucumber.core.exception.CucumberException) Failure(org.junit.runner.notification.Failure) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 14 with TestStepStarted

use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.

the class JUnitReporterWithStepNotificationsTest method test_step_started_fires_test_started_for_step.

@Test
void test_step_started_fires_test_started_for_step() {
    jUnitReporter.startExecutionUnit(pickleRunner, runNotifier);
    bus.send(new TestCaseStarted(now(), testCase));
    bus.send(new TestStepStarted(now(), testCase, mockTestStep(step)));
    jUnitReporter.finishExecutionUnit();
}
Also used : TestStepStarted(io.cucumber.plugin.event.TestStepStarted) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) Test(org.junit.jupiter.api.Test)

Example 15 with TestStepStarted

use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.

the class JUnitReporterWithStepNotificationsTest method test_case_finished_fires_test_finished_for_pickle.

@Test
void test_case_finished_fires_test_finished_for_pickle() {
    jUnitReporter.startExecutionUnit(pickleRunner, runNotifier);
    bus.send(new TestCaseStarted(now(), testCase));
    bus.send(new TestStepStarted(now(), testCase, mockTestStep(step)));
    Result result = new Result(Status.PASSED, ZERO, null);
    bus.send(new TestStepFinished(now(), testCase, mockTestStep(step), result));
    bus.send(new TestCaseFinished(now(), testCase, result));
    verify(runNotifier).fireTestStarted(pickleRunner.describeChild(step));
    verify(runNotifier).fireTestFinished(pickleRunner.describeChild(step));
}
Also used : TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) TestStepStarted(io.cucumber.plugin.event.TestStepStarted) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Aggregations

TestStepStarted (io.cucumber.plugin.event.TestStepStarted)18 Test (org.junit.jupiter.api.Test)17 TestCaseStarted (io.cucumber.plugin.event.TestCaseStarted)15 TestStepFinished (io.cucumber.plugin.event.TestStepFinished)15 Result (io.cucumber.plugin.event.Result)14 TestCaseFinished (io.cucumber.plugin.event.TestCaseFinished)14 Failure (org.junit.runner.notification.Failure)7 CucumberException (io.cucumber.core.exception.CucumberException)4 AssumptionViolatedException (org.junit.AssumptionViolatedException)4 TestAbortedException (org.opentest4j.TestAbortedException)4 MultipleFailureException (org.junit.runners.model.MultipleFailureException)3 EventBus (io.cucumber.core.eventbus.EventBus)2 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)2 SnippetsSuggestedEvent (io.cucumber.plugin.event.SnippetsSuggestedEvent)2 Suggestion (io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion)2 UUID (java.util.UUID)2 Feature (io.cucumber.core.gherkin.Feature)1 Envelope (io.cucumber.messages.types.Envelope)1 EventHandler (io.cucumber.plugin.event.EventHandler)1 PickleStepTestStep (io.cucumber.plugin.event.PickleStepTestStep)1