Search in sources :

Example 1 with Envelope

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

the class StepExpressionFactoryTest method throws_for_unknown_parameter_types.

@Test
void throws_for_unknown_parameter_types() {
    StepDefinition stepDefinition = new StubStepDefinition("Given a {unknownParameterType}");
    List<Envelope> events = new ArrayList<>();
    bus.registerHandlerFor(Envelope.class, events::add);
    CucumberException exception = assertThrows(CucumberException.class, () -> stepExpressionFactory.createExpression(stepDefinition));
    assertThat(exception.getMessage(), is("" + "Could not create a cucumber expression for 'Given a {unknownParameterType}'.\n" + "It appears you did not register a parameter type."));
    assertThat(events, iterableWithSize(1));
    assertNotNull(events.get(0).getUndefinedParameterType());
}
Also used : ArrayList(java.util.ArrayList) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) StepDefinition(io.cucumber.core.backend.StepDefinition) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) CucumberException(io.cucumber.core.exception.CucumberException) Envelope(io.cucumber.messages.types.Envelope) Test(org.junit.jupiter.api.Test)

Example 2 with Envelope

use of io.cucumber.messages.types.Envelope 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)

Example 3 with Envelope

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

the class TestCase method emitTestCaseMessage.

private void emitTestCaseMessage(EventBus bus) {
    Envelope envelope = new Envelope();
    envelope.setTestCase(new io.cucumber.messages.types.TestCase(id.toString(), pickle.getId(), getTestSteps().stream().map(this::createTestStep).collect(toList())));
    bus.send(envelope);
}
Also used : Envelope(io.cucumber.messages.types.Envelope)

Example 4 with Envelope

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

the class TestCase method emitTestCaseStarted.

private void emitTestCaseStarted(EventBus bus, Instant start, UUID executionId) {
    bus.send(new TestCaseStarted(start, this));
    Envelope envelope = new Envelope();
    envelope.setTestCaseStarted(new io.cucumber.messages.types.TestCaseStarted(0L, executionId.toString(), id.toString(), javaInstantToTimestamp(start)));
    bus.send(envelope);
}
Also used : Envelope(io.cucumber.messages.types.Envelope) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted)

Example 5 with Envelope

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

the class TestStep method emitTestStepStarted.

private void emitTestStepStarted(TestCase testCase, EventBus bus, UUID textExecutionId, Instant startTime) {
    bus.send(new TestStepStarted(startTime, testCase, this));
    Envelope envelope = new Envelope();
    envelope.setTestStepStarted(new io.cucumber.messages.types.TestStepStarted(textExecutionId.toString(), id.toString(), javaInstantToTimestamp(startTime)));
    bus.send(envelope);
}
Also used : Envelope(io.cucumber.messages.types.Envelope) TestStepStarted(io.cucumber.plugin.event.TestStepStarted)

Aggregations

Envelope (io.cucumber.messages.types.Envelope)22 UUID (java.util.UUID)8 Test (org.junit.jupiter.api.Test)8 EventBus (io.cucumber.core.eventbus.EventBus)5 Feature (io.cucumber.core.gherkin.Feature)5 ArrayList (java.util.ArrayList)5 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)4 StepDefinition (io.cucumber.core.backend.StepDefinition)3 TestRunFinished (io.cucumber.messages.types.TestRunFinished)3 TestRunStarted (io.cucumber.messages.types.TestRunStarted)3 Timestamp (io.cucumber.messages.types.Timestamp)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 URI (java.net.URI)3 List (java.util.List)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 HookDefinition (io.cucumber.core.backend.HookDefinition)2 ScenarioScoped (io.cucumber.core.backend.ScenarioScoped)2 TestCaseState (io.cucumber.core.backend.TestCaseState)2 TestFeatureParser (io.cucumber.core.feature.TestFeatureParser)2 EmbedEvent (io.cucumber.plugin.event.EmbedEvent)2