use of io.cucumber.plugin.event.EventHandler in project cucumber-jvm by cucumber.
the class EventBusTest method handlers_do_not_receive_the_events_they_did_not_registered_for.
@Test
void handlers_do_not_receive_the_events_they_did_not_registered_for() {
EventHandler handler = mock(EventHandler.class);
PickleStepTestStep testStep = mock(PickleStepTestStep.class);
TestCase testCase = mock(TestCase.class);
TestStepStarted event = new TestStepStarted(EPOCH, testCase, testStep);
EventBus bus = new TimeServiceEventBus(Clock.fixed(Instant.EPOCH, ZoneId.of("UTC")), UUID::randomUUID);
bus.registerHandlerFor(TestStepFinished.class, handler);
bus.send(event);
verify(handler, never()).receive(event);
}
use of io.cucumber.plugin.event.EventHandler 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));
}
Aggregations