use of io.cucumber.core.backend.HookDefinition in project cucumber-jvm by cucumber.
the class RunnerTest method hooks_not_executed_in_dry_run_mode.
@Test
void hooks_not_executed_in_dry_run_mode() {
RuntimeOptions runtimeOptions = new RuntimeOptionsBuilder().setDryRun().build();
StaticHookDefinition beforeAllHook = createStaticHook();
StaticHookDefinition afterAllHook = createStaticHook();
HookDefinition beforeHook = createHook();
HookDefinition afterHook = createHook();
HookDefinition beforeStepHook = createHook();
HookDefinition afterStepHook = createHook();
TestRunnerSupplier runnerSupplier = new TestRunnerSupplier(bus, runtimeOptions) {
@Override
public void loadGlue(Glue glue, List<URI> gluePaths) {
glue.addBeforeAllHook(beforeAllHook);
glue.addAfterAllHook(afterAllHook);
glue.addBeforeHook(beforeHook);
glue.addAfterHook(afterHook);
glue.addBeforeStepHook(beforeStepHook);
glue.addAfterStepHook(afterStepHook);
}
};
runnerSupplier.get().runBeforeAllHooks();
runnerSupplier.get().runPickle(createPicklesWithSteps());
runnerSupplier.get().runAfterAllHooks();
verify(beforeAllHook, never()).execute();
verify(afterAllHook, never()).execute();
verify(beforeHook, never()).execute(any(TestCaseState.class));
verify(afterHook, never()).execute(any(TestCaseState.class));
verify(beforeStepHook, never()).execute(any(TestCaseState.class));
verify(afterStepHook, never()).execute(any(TestCaseState.class));
}
use of io.cucumber.core.backend.HookDefinition in project cucumber-jvm by cucumber.
the class CachingGlueTest method sorts_after_hooks_in_reverse_order.
@Test
void sorts_after_hooks_in_reverse_order() {
HookDefinition hookDefinition1 = new MockedScenarioScopedHookDefinition(12);
HookDefinition hookDefinition2 = new MockedScenarioScopedHookDefinition(12);
HookDefinition hookDefinition3 = new MockedScenarioScopedHookDefinition(24);
glue.addAfterHook(hookDefinition1);
glue.addAfterHook(hookDefinition2);
glue.addAfterHook(hookDefinition3);
List<HookDefinition> hooks = glue.getAfterHooks().stream().map(CoreHookDefinition::getDelegate).collect(Collectors.toList());
assertThat(hooks, contains(hookDefinition3, hookDefinition2, hookDefinition1));
}
use of io.cucumber.core.backend.HookDefinition in project cucumber-jvm by cucumber.
the class CachingGlueTest method scenario_scoped_hooks_have_higher_order.
@Test
void scenario_scoped_hooks_have_higher_order() {
HookDefinition hookDefinition1 = new MockedScenarioScopedHookDefinition(12);
HookDefinition hookDefinition2 = new MockedHookDefinition(12);
HookDefinition hookDefinition3 = new MockedScenarioScopedHookDefinition(24);
glue.addBeforeHook(hookDefinition1);
glue.addBeforeHook(hookDefinition2);
glue.addBeforeHook(hookDefinition3);
List<HookDefinition> hooks = glue.getBeforeHooks().stream().map(CoreHookDefinition::getDelegate).collect(Collectors.toList());
assertThat(hooks, contains(hookDefinition2, hookDefinition1, hookDefinition3));
}
use of io.cucumber.core.backend.HookDefinition in project cucumber-jvm by cucumber.
the class HookOrderTest method after_step_hooks_execute_in_reverse_order.
@Test
void after_step_hooks_execute_in_reverse_order() {
final List<HookDefinition> hooks = mockHooks(Integer.MIN_VALUE, 2, Integer.MAX_VALUE, 4, -1, 0, 10000);
TestRunnerSupplier runnerSupplier = new TestRunnerSupplier(bus, runtimeOptions) {
@Override
public void loadGlue(Glue glue, List<URI> gluePaths) {
glue.addStepDefinition(stepDefinition);
for (HookDefinition hook : hooks) {
glue.addAfterStepHook(hook);
}
}
};
runnerSupplier.get().runPickle(pickle);
InOrder inOrder = inOrder(hooks.toArray());
inOrder.verify(hooks.get(2)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(6)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(3)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(1)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(5)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(4)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(0)).execute(ArgumentMatchers.any());
}
use of io.cucumber.core.backend.HookDefinition in project cucumber-jvm by cucumber.
the class HookOrderTest method after_hooks_execute_in_reverse_order.
@Test
void after_hooks_execute_in_reverse_order() {
final List<HookDefinition> hooks = mockHooks(Integer.MIN_VALUE, 2, Integer.MAX_VALUE, 4, -1, 0, 10000);
TestRunnerSupplier runnerSupplier = new TestRunnerSupplier(bus, runtimeOptions) {
@Override
public void loadGlue(Glue glue, List<URI> gluePaths) {
glue.addStepDefinition(stepDefinition);
for (HookDefinition hook : hooks) {
glue.addAfterHook(hook);
}
}
};
runnerSupplier.get().runPickle(pickle);
InOrder inOrder = inOrder(hooks.toArray());
inOrder.verify(hooks.get(2)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(6)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(3)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(1)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(5)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(4)).execute(ArgumentMatchers.any());
inOrder.verify(hooks.get(0)).execute(ArgumentMatchers.any());
}
Aggregations