use of io.cucumber.plugin.event.TestStepFinished 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.TestStepFinished in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method should_be_skipped_for_skipped_result.
@Test
public void should_be_skipped_for_skipped_result() {
TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
Result stepResult = new Result(SKIPPED, ZERO, null);
bus.send(new TestStepFinished(now(), testCase, step, stepResult));
Result testCaseResult = new Result(SKIPPED, ZERO, null);
bus.send(new TestCaseFinished(now(), testCase, testCaseResult));
Exception exception = expectThrows(Exception.class, resultListener::assertTestCasePassed);
assertThat(exception.getCause(), instanceOf(SkipException.class));
}
use of io.cucumber.plugin.event.TestStepFinished in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method should_be_skipped_for_pending_result.
@Test
public void should_be_skipped_for_pending_result() {
TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
Exception error = new TestPendingException();
Result stepResult = new Result(PENDING, ZERO, error);
bus.send(new TestStepFinished(now(), testCase, step, stepResult));
Result testCaseResult = new Result(PENDING, ZERO, error);
bus.send(new TestCaseFinished(now(), testCase, testCaseResult));
Exception exception = expectThrows(Exception.class, resultListener::assertTestCasePassed);
assertThat(exception.getCause(), is(error));
}
use of io.cucumber.plugin.event.TestStepFinished in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method should_not_be_passed_for_failed_result.
@Test
public void should_not_be_passed_for_failed_result() {
TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
Result stepResult = new Result(FAILED, ZERO, error);
bus.send(new TestStepFinished(now(), testCase, step, stepResult));
Result testCaseResult = new Result(FAILED, ZERO, error);
bus.send(new TestCaseFinished(now(), testCase, testCaseResult));
Exception exception = expectThrows(Exception.class, resultListener::assertTestCasePassed);
assertEquals(exception.getCause(), error);
}
use of io.cucumber.plugin.event.TestStepFinished in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method should_be_failed_for_undefined_result.
@Test
public void should_be_failed_for_undefined_result() {
TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
bus.send(new SnippetsSuggestedEvent(now(), uri, location, location, new Suggestion("some step", singletonList("stub snippet"))));
Result stepResult = new Result(UNDEFINED, ZERO, error);
bus.send(new TestStepFinished(now(), testCase, step, stepResult));
Result testCaseResult = new Result(UNDEFINED, ZERO, error);
bus.send(new TestCaseFinished(now(), testCase, testCaseResult));
Exception exception = expectThrows(Exception.class, resultListener::assertTestCasePassed);
assertThat(exception.getCause(), instanceOf(SkipException.class));
SkipException skipException = (SkipException) exception.getCause();
assertThat(skipException.isSkip(), is(false));
assertThat(skipException.getMessage(), is("" + "The step 'some step' is undefined.\n" + "You can implement this step using the snippet(s) below:\n" + "\n" + "stub snippet\n"));
}
Aggregations