Search in sources :

Example 6 with StepTypeRegistry

use of io.cucumber.core.stepexpression.StepTypeRegistry 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));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) DataTableTypeDefinition(io.cucumber.core.backend.DataTableTypeDefinition) ParameterTypeDefinition(io.cucumber.core.backend.ParameterTypeDefinition) IsIterableContainingInOrder.contains(org.hamcrest.collection.IsIterableContainingInOrder.contains) SourceReference(io.cucumber.core.backend.SourceReference) Step(io.cucumber.core.gherkin.Step) DefaultDataTableCellTransformerDefinition(io.cucumber.core.backend.DefaultDataTableCellTransformerDefinition) DefaultDataTableEntryTransformerDefinition(io.cucumber.core.backend.DefaultDataTableEntryTransformerDefinition) DefaultParameterTransformerDefinition(io.cucumber.core.backend.DefaultParameterTransformerDefinition) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) DataTableType(io.cucumber.datatable.DataTableType) ScenarioScoped(io.cucumber.core.backend.ScenarioScoped) ArrayList(java.util.ArrayList) StepDefinition(io.cucumber.core.backend.StepDefinition) TestCaseState(io.cucumber.core.backend.TestCaseState) Is.is(org.hamcrest.core.Is.is) Assertions.assertAll(org.junit.jupiter.api.Assertions.assertAll) URI(java.net.URI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ENGLISH(java.util.Locale.ENGLISH) DataTable(io.cucumber.datatable.DataTable) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) EventBus(io.cucumber.core.eventbus.EventBus) HookDefinition(io.cucumber.core.backend.HookDefinition) TestFeatureParser(io.cucumber.core.feature.TestFeatureParser) StepTypeRegistry(io.cucumber.core.stepexpression.StepTypeRegistry) Envelope(io.cucumber.messages.types.Envelope) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) UUID(java.util.UUID) Mockito.when(org.mockito.Mockito.when) EventHandler(io.cucumber.plugin.event.EventHandler) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) Type(java.lang.reflect.Type) ParameterByTypeTransformer(io.cucumber.cucumberexpressions.ParameterByTypeTransformer) TableCellByTypeTransformer(io.cucumber.datatable.TableCellByTypeTransformer) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Feature(io.cucumber.core.gherkin.Feature) DocStringType(io.cucumber.docstring.DocStringType) Clock(java.time.Clock) Optional(java.util.Optional) TableEntryByTypeTransformer(io.cucumber.datatable.TableEntryByTypeTransformer) DocStringTypeDefinition(io.cucumber.core.backend.DocStringTypeDefinition) ParameterType(io.cucumber.cucumberexpressions.ParameterType) Mockito.mock(org.mockito.Mockito.mock) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) ArrayList(java.util.ArrayList) EventBus(io.cucumber.core.eventbus.EventBus) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) Envelope(io.cucumber.messages.types.Envelope) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

StepTypeRegistry (io.cucumber.core.stepexpression.StepTypeRegistry)6 StepDefinition (io.cucumber.core.backend.StepDefinition)4 Test (org.junit.jupiter.api.Test)4 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)3 BytesContainsString.bytesContainsString (io.cucumber.core.plugin.BytesContainsString.bytesContainsString)3 StepExpression (io.cucumber.core.stepexpression.StepExpression)3 StepExpressionFactory (io.cucumber.core.stepexpression.StepExpressionFactory)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 DataTableTypeDefinition (io.cucumber.core.backend.DataTableTypeDefinition)1 DefaultDataTableCellTransformerDefinition (io.cucumber.core.backend.DefaultDataTableCellTransformerDefinition)1 DefaultDataTableEntryTransformerDefinition (io.cucumber.core.backend.DefaultDataTableEntryTransformerDefinition)1 DefaultParameterTransformerDefinition (io.cucumber.core.backend.DefaultParameterTransformerDefinition)1 DocStringTypeDefinition (io.cucumber.core.backend.DocStringTypeDefinition)1 HookDefinition (io.cucumber.core.backend.HookDefinition)1 ParameterTypeDefinition (io.cucumber.core.backend.ParameterTypeDefinition)1 ScenarioScoped (io.cucumber.core.backend.ScenarioScoped)1 SourceReference (io.cucumber.core.backend.SourceReference)1 TestCaseState (io.cucumber.core.backend.TestCaseState)1 EventBus (io.cucumber.core.eventbus.EventBus)1 TestFeatureParser (io.cucumber.core.feature.TestFeatureParser)1