Search in sources :

Example 1 with TestRunStarted

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

the class CucumberExecutionContextTest method emits_failures_in_events.

@Test
public void emits_failures_in_events() {
    List<TestRunStarted> testRunStarted = new ArrayList<>();
    List<TestRunFinished> testRunFinished = new ArrayList<>();
    bus.registerHandlerFor(TestRunStarted.class, testRunStarted::add);
    bus.registerHandlerFor(TestRunFinished.class, testRunFinished::add);
    context.startTestRun();
    assertThrows(IllegalStateException.class, () -> context.runTestCase(runner -> {
        throw failure;
    }));
    context.finishTestRun();
    assertThat(testRunStarted.get(0), notNullValue());
    Result result = testRunFinished.get(0).getResult();
    assertThat(result.getStatus(), is(Status.FAILED));
    assertThat(result.getError(), is(failure));
}
Also used : TestRunStarted(io.cucumber.plugin.event.TestRunStarted) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Result(io.cucumber.plugin.event.Result) TestRunStarted(io.cucumber.plugin.event.TestRunStarted) Status(io.cucumber.plugin.event.Status) UUID(java.util.UUID) TestCase(io.cucumber.plugin.event.TestCase) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) Test(org.junit.jupiter.api.Test) RuntimeOptions(io.cucumber.core.options.RuntimeOptions) List(java.util.List) RuntimeOptionsBuilder(io.cucumber.core.options.RuntimeOptionsBuilder) TestRunFinished(io.cucumber.plugin.event.TestRunFinished) TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) Duration(java.time.Duration) Clock(java.time.Clock) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) EventBus(io.cucumber.core.eventbus.EventBus) Mockito.mock(org.mockito.Mockito.mock) ArrayList(java.util.ArrayList) TestRunFinished(io.cucumber.plugin.event.TestRunFinished) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 2 with TestRunStarted

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

the class CucumberExecutionContext method emitTestRunStarted.

private void emitTestRunStarted() {
    log.debug(() -> "Sending run test started event");
    start = bus.getInstant();
    bus.send(new TestRunStarted(start));
    Envelope envelope = new Envelope();
    envelope.setTestRunStarted(new io.cucumber.messages.types.TestRunStarted(javaInstantToTimestamp(start)));
    bus.send(envelope);
}
Also used : TestRunStarted(io.cucumber.plugin.event.TestRunStarted) Envelope(io.cucumber.messages.types.Envelope)

Aggregations

TestRunStarted (io.cucumber.plugin.event.TestRunStarted)2 EventBus (io.cucumber.core.eventbus.EventBus)1 RuntimeOptions (io.cucumber.core.options.RuntimeOptions)1 RuntimeOptionsBuilder (io.cucumber.core.options.RuntimeOptionsBuilder)1 Envelope (io.cucumber.messages.types.Envelope)1 Result (io.cucumber.plugin.event.Result)1 Status (io.cucumber.plugin.event.Status)1 TestCase (io.cucumber.plugin.event.TestCase)1 TestCaseFinished (io.cucumber.plugin.event.TestCaseFinished)1 TestRunFinished (io.cucumber.plugin.event.TestRunFinished)1 Clock (java.time.Clock)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 CoreMatchers.notNullValue (org.hamcrest.CoreMatchers.notNullValue)1 CoreMatchers.nullValue (org.hamcrest.CoreMatchers.nullValue)1