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());
}
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"));
}
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);
}
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);
}
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);
}
Aggregations