Search in sources :

Example 31 with Result

use of io.cucumber.plugin.event.Result in project syndesis-qe by syndesisio.

the class PrettyFormatter method printError.

private void printError(TestStepFinished event) {
    Result result = event.getResult();
    Throwable error = result.getError();
    if (error != null) {
        String name = result.getStatus().name().toLowerCase(ROOT);
        String text = printStackTrace(error);
        out.println("      " + formats.get(name).text(text));
    }
}
Also used : Result(io.cucumber.plugin.event.Result)

Example 32 with Result

use of io.cucumber.plugin.event.Result 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);
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) TestCase(io.cucumber.plugin.event.TestCase) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) EventBus(io.cucumber.core.eventbus.EventBus) UUID(java.util.UUID) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 33 with Result

use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.

the class PickleStepTestStepTest method result_is_result_from_hook_when_before_step_hook_does_not_pass.

@Test
void result_is_result_from_hook_when_before_step_hook_does_not_pass() {
    Exception exception = new RuntimeException();
    doThrow(exception).when(beforeHookDefinition).execute(any(TestCaseState.class));
    Result failure = new Result(Status.FAILED, ZERO, exception);
    ExecutionMode nextExecutionMode = step.run(testCase, bus, state, ExecutionMode.RUN);
    assertThat(nextExecutionMode, is(ExecutionMode.SKIP));
    assertThat(state.getStatus(), is(equalTo(FAILED)));
    ArgumentCaptor<TestCaseEvent> captor = forClass(TestCaseEvent.class);
    verify(bus, times(12)).send(captor.capture());
    List<TestCaseEvent> allValues = captor.getAllValues();
    assertThat(((TestStepFinished) allValues.get(2)).getResult(), is(equalTo(failure)));
}
Also used : TestCaseEvent(io.cucumber.plugin.event.TestCaseEvent) StubPendingException(io.cucumber.core.backend.StubPendingException) TestAbortedException(org.opentest4j.TestAbortedException) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 34 with Result

use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.

the class ResultTest method is_query_returns_false_for_statuses_different_from_the_status_of_the_result_object.

@Test
void is_query_returns_false_for_statuses_different_from_the_status_of_the_result_object() {
    int checkCount = 0;
    for (Status resultStatus : Status.values()) {
        Result result = new Result(resultStatus, ZERO, null);
        for (Status status : Status.values()) {
            if (status != resultStatus) {
                assertFalse(result.getStatus().is(status));
                checkCount += 1;
            }
        }
    }
    assertThat("No checks performed", checkCount > 0, is(equalTo(true)));
}
Also used : Status(io.cucumber.plugin.event.Status) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 35 with Result

use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.

the class ResultTest method skipped_result_is_ok.

@Test
void skipped_result_is_ok() {
    Result skippedResult = new Result(SKIPPED, ZERO, null);
    assertTrue(skippedResult.getStatus().isOk());
}
Also used : Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Aggregations

Result (io.cucumber.plugin.event.Result)56 Test (org.junit.jupiter.api.Test)41 TestStepFinished (io.cucumber.plugin.event.TestStepFinished)29 TestCaseFinished (io.cucumber.plugin.event.TestCaseFinished)26 TestCaseStarted (io.cucumber.plugin.event.TestCaseStarted)15 TestStepStarted (io.cucumber.plugin.event.TestStepStarted)14 Test (org.testng.annotations.Test)9 UUID (java.util.UUID)7 Failure (org.junit.runner.notification.Failure)7 SkipException (org.testng.SkipException)7 PickleStepTestStep (io.cucumber.plugin.event.PickleStepTestStep)6 Status (io.cucumber.plugin.event.Status)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 List (java.util.List)6 TestAbortedException (org.opentest4j.TestAbortedException)6 EventBus (io.cucumber.core.eventbus.EventBus)5 SnippetsSuggestedEvent (io.cucumber.plugin.event.SnippetsSuggestedEvent)5 Suggestion (io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion)5 TestRunFinished (io.cucumber.plugin.event.TestRunFinished)5 OutputStream (java.io.OutputStream)5