use of io.cucumber.plugin.event.TestStepFinished in project cucumber-jvm by cucumber.
the class TestCaseResultObserverTest method should_not_be_skipped_for_undefined_result.
@Test
public void should_not_be_skipped_for_undefined_result() {
TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
bus.send(new SnippetsSuggestedEvent(now(), uri, location, location, new SnippetsSuggestedEvent.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"));
}
use of io.cucumber.plugin.event.TestStepFinished 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.TestStepFinished 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.TestStepFinished 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.TestStepFinished in project cucumber-jvm by cucumber.
the class EventBusTest method handlers_receive_the_events_they_registered_for.
@Test
void handlers_receive_the_events_they_registered_for() {
EventHandler<TestStepFinished> handler = mock(EventHandler.class);
PickleStepTestStep testStep = mock(PickleStepTestStep.class);
Result result = new Result(Status.PASSED, ZERO, null);
TestCase testCase = mock(TestCase.class);
TestStepFinished event = new TestStepFinished(EPOCH, testCase, testStep, result);
EventBus bus = new TimeServiceEventBus(Clock.fixed(Instant.EPOCH, ZoneId.of("UTC")), UUID::randomUUID);
bus.registerHandlerFor(TestStepFinished.class, handler);
bus.send(event);
verify(handler).receive(event);
}
Aggregations