Search in sources :

Example 1 with StepDefinition

use of io.cucumber.messages.types.StepDefinition in project cucumber-jvm by cucumber.

the class HtmlFormatterTest method ignores_step_definitions.

@Test
void ignores_step_definitions() throws Throwable {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    HtmlFormatter formatter = new HtmlFormatter(bytes);
    EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
    formatter.setEventPublisher(bus);
    TestRunStarted testRunStarted = new TestRunStarted();
    testRunStarted.setTimestamp(new Timestamp(10L, 0L));
    Envelope testRunStartedEnvelope = new Envelope();
    testRunStartedEnvelope.setTestRunStarted(testRunStarted);
    bus.send(testRunStartedEnvelope);
    StepDefinition stepDefinition = new StepDefinition();
    Envelope stepDefinitionEnvelope = new Envelope();
    stepDefinitionEnvelope.setStepDefinition(stepDefinition);
    bus.send(stepDefinitionEnvelope);
    Hook hook = new Hook();
    Envelope hookEnvelope = new Envelope();
    hookEnvelope.setHook(hook);
    bus.send(hookEnvelope);
    ParameterType parameterType = new ParameterType();
    Envelope parameterTypeEnvelope = new Envelope();
    parameterTypeEnvelope.setParameterType(parameterType);
    bus.send(parameterTypeEnvelope);
    TestRunFinished testRunFinished = new TestRunFinished();
    testRunFinished.setTimestamp(new Timestamp(15L, 0L));
    Envelope testRunFinishedEnvelope = new Envelope();
    testRunFinishedEnvelope.setTestRunFinished(testRunFinished);
    bus.send(testRunFinishedEnvelope);
    String html = new String(bytes.toByteArray(), UTF_8);
    assertThat(html, containsString("" + "window.CUCUMBER_MESSAGES = [" + "{\"testRunStarted\":{\"timestamp\":{\"seconds\":10,\"nanos\":0}}}," + "{\"testRunFinished\":{\"timestamp\":{\"seconds\":15,\"nanos\":0}}}" + "];\n"));
}
Also used : Hook(io.cucumber.messages.types.Hook) ParameterType(io.cucumber.messages.types.ParameterType) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) EventBus(io.cucumber.core.eventbus.EventBus) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Envelope(io.cucumber.messages.types.Envelope) TestRunFinished(io.cucumber.messages.types.TestRunFinished) Timestamp(io.cucumber.messages.types.Timestamp) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) TestRunStarted(io.cucumber.messages.types.TestRunStarted) StepDefinition(io.cucumber.messages.types.StepDefinition) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

EventBus (io.cucumber.core.eventbus.EventBus)1 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)1 Envelope (io.cucumber.messages.types.Envelope)1 Hook (io.cucumber.messages.types.Hook)1 ParameterType (io.cucumber.messages.types.ParameterType)1 StepDefinition (io.cucumber.messages.types.StepDefinition)1 TestRunFinished (io.cucumber.messages.types.TestRunFinished)1 TestRunStarted (io.cucumber.messages.types.TestRunStarted)1 Timestamp (io.cucumber.messages.types.Timestamp)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 UUID (java.util.UUID)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.jupiter.api.Test)1