|
11 | 11 | import io.cucumber.core.backend.SourceReference;
|
12 | 12 | import io.cucumber.core.backend.StepDefinition;
|
13 | 13 | import io.cucumber.core.backend.TestCaseState;
|
| 14 | +import io.cucumber.core.eventbus.EventBus; |
14 | 15 | import io.cucumber.core.feature.TestFeatureParser;
|
15 | 16 | import io.cucumber.core.gherkin.Feature;
|
16 | 17 | import io.cucumber.core.gherkin.Step;
|
|
24 | 25 | import io.cucumber.datatable.TableEntryByTypeTransformer;
|
25 | 26 | import io.cucumber.docstring.DocStringType;
|
26 | 27 | import org.junit.jupiter.api.Test;
|
| 28 | +import io.cucumber.messages.Messages; |
| 29 | +import io.cucumber.plugin.event.EventHandler; |
27 | 30 |
|
28 | 31 | import java.lang.reflect.Type;
|
29 | 32 | import java.net.URI;
|
30 | 33 | import java.time.Clock;
|
| 34 | +import java.util.ArrayList; |
31 | 35 | import java.util.List;
|
32 | 36 | import java.util.Optional;
|
33 | 37 | import java.util.UUID;
|
@@ -458,6 +462,25 @@ void scenario_scoped_hooks_have_higher_order() {
|
458 | 462 |
|
459 | 463 | assertThat(hooks, contains(hookDefinition2, hookDefinition1, hookDefinition3));
|
460 | 464 | }
|
| 465 | + |
| 466 | + @Test |
| 467 | + public void emits_hook_messages_to_bus() { |
| 468 | + |
| 469 | + List<Messages.Envelope> events = new ArrayList<>(); |
| 470 | + EventHandler<Messages.Envelope> messageEventHandler = e -> events.add(e); |
| 471 | + |
| 472 | + EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID); |
| 473 | + bus.registerHandlerFor(Messages.Envelope.class, messageEventHandler); |
| 474 | + CachingGlue glue = new CachingGlue(bus); |
| 475 | + |
| 476 | + glue.addBeforeHook(new MockedScenarioScopedHookDefinition()); |
| 477 | + glue.addAfterHook(new MockedScenarioScopedHookDefinition()); |
| 478 | + glue.addBeforeStepHook(new MockedScenarioScopedHookDefinition()); |
| 479 | + glue.addAfterStepHook(new MockedScenarioScopedHookDefinition()); |
| 480 | + |
| 481 | + glue.prepareGlue(stepTypeRegistry); |
| 482 | + assertThat(events.size(), is(4)); |
| 483 | + } |
461 | 484 |
|
462 | 485 | private static class MockedScenarioScopedStepDefinition extends StubStepDefinition implements ScenarioScoped {
|
463 | 486 |
|
@@ -773,5 +796,4 @@ public boolean isDisposed() {
|
773 | 796 | }
|
774 | 797 |
|
775 | 798 | }
|
776 |
| - |
777 | 799 | }
|
0 commit comments