use of io.cucumber.plugin.event.TestStepFinished 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));
}
use of io.cucumber.plugin.event.TestStepFinished in project cucumber-jvm by cucumber.
the class JUnitReporterWithStepNotificationsTest method test_step_finished_fires_test_failure_and_test_finished_for_failed_step_with_multiple_failure_exception.
@Test
void test_step_finished_fires_test_failure_and_test_finished_for_failed_step_with_multiple_failure_exception() {
jUnitReporter.startExecutionUnit(pickleRunner, runNotifier);
bus.send(new TestCaseStarted(now(), testCase));
bus.send(new TestStepStarted(now(), testCase, mockTestStep(step)));
List<Throwable> failures = asList(new Exception("Oops"), new Exception("I did it again"));
Throwable exception = new MultipleFailureException(failures);
Result result = new Result(Status.FAILED, ZERO, exception);
bus.send(new TestStepFinished(now(), testCase, mockTestStep(step), result));
verify(runNotifier, times(2)).fireTestFailure(failureArgumentCaptor.capture());
verify(runNotifier).fireTestFinished(pickleRunner.describeChild(step));
List<Failure> stepFailure = failureArgumentCaptor.getAllValues();
assertThat(stepFailure.get(0).getDescription(), is(equalTo(pickleRunner.describeChild(step))));
assertThat(stepFailure.get(0).getException(), is(equalTo(failures.get(0))));
assertThat(stepFailure.get(1).getDescription(), is(equalTo(pickleRunner.describeChild(step))));
assertThat(stepFailure.get(1).getException(), is(equalTo(failures.get(1))));
bus.send(new TestCaseFinished(now(), testCase, result));
verify(runNotifier, times(4)).fireTestFailure(failureArgumentCaptor.capture());
verify(runNotifier).fireTestFinished(pickleRunner.describeChild(step));
List<Failure> pickleFailure = failureArgumentCaptor.getAllValues();
// Mockito recapture all arguments on .capture() so we end up with the
// original 2, those 2 repeated and the finally the 2 we expect.
assertThat(pickleFailure.get(4).getDescription(), is(equalTo(pickleRunner.getDescription())));
assertThat(pickleFailure.get(4).getException(), is(equalTo(failures.get(0))));
assertThat(pickleFailure.get(5).getDescription(), is(equalTo(pickleRunner.getDescription())));
assertThat(pickleFailure.get(5).getException(), is(equalTo(failures.get(1))));
}
use of io.cucumber.plugin.event.TestStepFinished in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method skippedByDryRun.
@Test
void skippedByDryRun() {
bus.send(new TestCaseStarted(Instant.now(), testCase));
bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
Result result = new Result(Status.SKIPPED, 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(TestAbortedException.class));
}
use of io.cucumber.plugin.event.TestStepFinished in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method skippedByUser.
@Test
void skippedByUser() {
bus.send(new TestCaseStarted(Instant.now(), testCase));
bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
Result result = new Result(Status.SKIPPED, Duration.ZERO, new TestAbortedException("thrown by user"));
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(TestAbortedException.class));
}
use of io.cucumber.plugin.event.TestStepFinished in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method should_not_be_passed_for_ambiguous_result.
@Test
public void should_not_be_passed_for_ambiguous_result() {
TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
Result stepResult = new Result(AMBIGUOUS, ZERO, error);
bus.send(new TestStepFinished(now(), testCase, step, stepResult));
Result testCaseResult = new Result(AMBIGUOUS, ZERO, error);
bus.send(new TestCaseFinished(now(), testCase, testCaseResult));
Exception exception = expectThrows(Exception.class, resultListener::assertTestCasePassed);
assertEquals(exception.getCause(), error);
}
Aggregations