use of io.cucumber.plugin.event.TestCaseFinished in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method empty.
@Test
void empty() {
bus.send(new TestCaseStarted(Instant.now(), testCase));
Result result = new Result(Status.PASSED, Duration.ZERO, null);
bus.send(new TestCaseFinished(Instant.now(), testCase, result));
observer.assertTestCasePassed();
}
use of io.cucumber.plugin.event.TestCaseFinished 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.TestCaseFinished 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.TestCaseFinished in project cucumber-jvm by cucumber.
the class CucumberExecutionContextTest method rethrows_but_does_not_collect_failures_in_test_case.
@Test
public void rethrows_but_does_not_collect_failures_in_test_case() {
IllegalStateException thrown = assertThrows(IllegalStateException.class, () -> context.runTestCase(runner -> {
try (TestCaseResultObserver r = new TestCaseResultObserver(bus)) {
bus.send(new TestCaseFinished(bus.getInstant(), mock(TestCase.class), new Result(Status.FAILED, Duration.ZERO, failure)));
r.assertTestCasePassed(Exception::new, Function.identity(), (suggestions) -> new Exception(), Function.identity());
}
}));
assertThat(thrown, is(failure));
assertThat(context.getThrowable(), nullValue());
}
use of io.cucumber.plugin.event.TestCaseFinished 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