use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.
the class JUnitReporterWithStepNotificationsTest method test_step_finished_fires_assumption_failed_and_test_finished_for_skipped_step_with_assumption_violated.
@Test
void test_step_finished_fires_assumption_failed_and_test_finished_for_skipped_step_with_assumption_violated() {
jUnitReporter.startExecutionUnit(pickleRunner, runNotifier);
bus.send(new TestCaseStarted(now(), testCase));
bus.send(new TestStepStarted(now(), testCase, mockTestStep(step)));
Throwable exception = new AssumptionViolatedException("Oops");
Result result = new Result(Status.SKIPPED, ZERO, exception);
bus.send(new TestStepFinished(now(), testCase, mockTestStep(step), result));
verify(runNotifier).fireTestAssumptionFailed(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)).fireTestAssumptionFailed(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)));
}
use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method undefined.
@Test
void undefined() {
bus.send(new TestCaseStarted(Instant.now(), testCase));
bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
bus.send(new SnippetsSuggestedEvent(Instant.now(), uri, testCase.getLocation(), testStep.getStep().getLocation(), new Suggestion(testStep.getStep().getText(), asList("mocked snippet 1", "mocked snippet 2", "mocked snippet 3"))));
Result result = new Result(Status.UNDEFINED, Duration.ZERO, null);
bus.send(new TestStepFinished(Instant.now(), testCase, testStep, result));
bus.send(new TestCaseFinished(Instant.now(), testCase, result));
Exception exception = assertThrows(Exception.class, observer::assertTestCasePassed);
assertThat(exception.getCause(), instanceOf(UndefinedStepException.class));
assertThat(exception.getCause().getMessage(), is("" + "The step 'mocked' is undefined.\n" + "You can implement this step using the snippet(s) below:\n" + "\n" + "mocked snippet 1\n" + "mocked snippet 2\n" + "mocked snippet 3\n"));
}
use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method passed.
@Test
void passed() {
bus.send(new TestCaseStarted(Instant.now(), testCase));
bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
Result result = new Result(Status.PASSED, Duration.ZERO, null);
bus.send(new TestStepFinished(Instant.now(), testCase, testStep, result));
bus.send(new TestCaseFinished(Instant.now(), testCase, result));
observer.assertTestCasePassed();
}
use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method failed.
@Test
void failed() {
bus.send(new TestCaseStarted(Instant.now(), testCase));
bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
Throwable error = new AssertionFailedError("Mocked");
Result result = new Result(Status.FAILED, Duration.ZERO, error);
bus.send(new TestStepFinished(Instant.now(), testCase, testStep, result));
bus.send(new TestCaseFinished(Instant.now(), testCase, result));
Exception exception = assertThrows(Exception.class, observer::assertTestCasePassed);
assertThat(exception.getCause(), is(error));
}
use of io.cucumber.plugin.event.TestStepStarted in project cucumber-jvm by cucumber.
the class JUnitReporterWithStepNotificationsTest method ignores_steps_when_step_notification_are_disabled.
@Test
void ignores_steps_when_step_notification_are_disabled() {
EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
JUnitReporter jUnitReporter = new JUnitReporter(bus, new JUnitOptionsBuilder().setStepNotifications(false).build());
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, never()).fireTestStarted(pickleRunner.describeChild(step));
verify(runNotifier, never()).fireTestFinished(pickleRunner.describeChild(step));
}
Aggregations