use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.
the class TestCase method emitTestCaseFinished.
private void emitTestCaseFinished(EventBus bus, UUID executionId, Instant stop, Duration duration, Status status, Result result) {
bus.send(new TestCaseFinished(stop, this, result));
TestStepResult testStepResult = new TestStepResult();
testStepResult.setStatus(from(status));
testStepResult.setDuration(javaDurationToDuration(duration));
if (result.getError() != null) {
testStepResult.setMessage(toString(result.getError()));
}
Envelope envelope = new Envelope();
envelope.setTestCaseFinished(new io.cucumber.messages.types.TestCaseFinished(executionId.toString(), javaInstantToTimestamp(stop), false));
bus.send(envelope);
}
use of io.cucumber.messages.types.Envelope 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);
}
use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.
the class CachingGlue method emitHook.
private void emitHook(CoreHookDefinition coreHook) {
Hook messagesHook = new Hook();
messagesHook.setId(coreHook.getId().toString());
messagesHook.setTagExpression(coreHook.getTagExpression());
coreHook.getDefinitionLocation().ifPresent(reference -> messagesHook.setSourceReference(createSourceReference(reference)));
Envelope envelope = new Envelope();
envelope.setHook(messagesHook);
bus.send(envelope);
}
use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.
the class CachingGlueTest method emits_hook_messages_to_bus.
@Test
public void emits_hook_messages_to_bus() {
List<Envelope> events = new ArrayList<>();
EventHandler<Envelope> messageEventHandler = e -> events.add(e);
EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
bus.registerHandlerFor(Envelope.class, messageEventHandler);
CachingGlue glue = new CachingGlue(bus);
glue.addBeforeHook(new MockedScenarioScopedHookDefinition());
glue.addAfterHook(new MockedScenarioScopedHookDefinition());
glue.addBeforeStepHook(new MockedScenarioScopedHookDefinition());
glue.addAfterStepHook(new MockedScenarioScopedHookDefinition());
glue.prepareGlue(stepTypeRegistry);
assertThat(events.size(), is(4));
}
use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.
the class HtmlFormatterTest method writes_index_html.
@Test
void writes_index_html() 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);
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"));
}
Aggregations