use of cucumber.runtime.HookDefinition in project cucumber-jvm by cucumber.
the class JavaHookTest method fails_if_hook_argument_is_not_scenario_result.
@Test
public void fails_if_hook_argument_is_not_scenario_result() throws Throwable {
objectFactory.setInstance(new BadHook());
backend.buildWorld();
backend.addHook(BAD_AFTER.getAnnotation(After.class), BAD_AFTER);
HookDefinition bad = glue.getAfterHooks().get(0);
try {
bad.execute(mock(Scenario.class));
fail();
} catch (CucumberException expected) {
assertEquals("When a hook declares an argument it must be of type cucumber.api.Scenario. public void cucumber.runtime.java.JavaHookTest$BadHook.after(java.lang.String)", expected.getMessage());
}
}
use of cucumber.runtime.HookDefinition in project cucumber-jvm by cucumber.
the class JavaHookTest method matches_matching_tags.
@Test
public void matches_matching_tags() {
objectFactory.setInstance(new HasHooks());
backend.buildWorld();
backend.addHook(BEFORE.getAnnotation(Before.class), BEFORE);
HookDefinition before = glue.getBeforeHooks().get(0);
assertTrue(before.matches(asList(new Tag("@bar", 0), new Tag("@zap", 0))));
}
use of cucumber.runtime.HookDefinition in project cucumber-jvm by cucumber.
the class JavaHookTest method hook_with_no_order_is_last.
@Test
public void hook_with_no_order_is_last() {
objectFactory.setInstance(new HasHooks());
backend.buildWorld();
backend.addHook(BEFORE.getAnnotation(Before.class), BEFORE);
HookDefinition hookDef = glue.getBeforeHooks().get(0);
assertEquals(10000, hookDef.getOrder());
}
use of cucumber.runtime.HookDefinition in project cucumber-jvm by cucumber.
the class JavaHookTest method hook_order_gets_registered.
@Test
public void hook_order_gets_registered() {
objectFactory.setInstance(new HasHooks());
backend.buildWorld();
backend.addHook(AFTER.getAnnotation(After.class), AFTER);
HookDefinition hookDef = glue.getAfterHooks().get(0);
assertEquals(1, hookDef.getOrder());
}
use of cucumber.runtime.HookDefinition in project cucumber-jvm by cucumber.
the class JavaHookTest method does_not_match_non_matching_tags.
@Test
public void does_not_match_non_matching_tags() {
objectFactory.setInstance(new HasHooks());
backend.buildWorld();
backend.addHook(BEFORE.getAnnotation(Before.class), BEFORE);
HookDefinition before = glue.getBeforeHooks().get(0);
assertFalse(before.matches(asList(new Tag("@bar", 0))));
}
Aggregations