use of gherkin.formatter.model.Tag 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 gherkin.formatter.model.Tag in project cucumber-jvm by cucumber.
the class HookOrderTest method after_hooks_execute_in_reverse_order.
@Test
public void after_hooks_execute_in_reverse_order() throws Throwable {
List<HookDefinition> hooks = mockHooks(Integer.MIN_VALUE, 2, Integer.MAX_VALUE, 4, -1, 0, 10000);
for (HookDefinition hook : hooks) {
glue.addAfterHook(hook);
}
runtime.runAfterHooks(mock(Reporter.class), new HashSet<Tag>());
InOrder inOrder = inOrder(hooks.toArray());
inOrder.verify(hooks.get(2)).execute(Matchers.<Scenario>any());
inOrder.verify(hooks.get(6)).execute(Matchers.<Scenario>any());
inOrder.verify(hooks.get(3)).execute(Matchers.<Scenario>any());
inOrder.verify(hooks.get(1)).execute(Matchers.<Scenario>any());
inOrder.verify(hooks.get(5)).execute(Matchers.<Scenario>any());
inOrder.verify(hooks.get(4)).execute(Matchers.<Scenario>any());
inOrder.verify(hooks.get(0)).execute(Matchers.<Scenario>any());
}
use of gherkin.formatter.model.Tag in project cucumber-jvm by cucumber.
the class HookTest method after_hooks_execute_before_objects_are_disposed.
/**
* Test for <a href="https://github.com/cucumber/cucumber-jvm/issues/23">#23</a>.
* TODO: ensure this is no longer needed with the alternate approach taken in Runtime
* TODO: this test is rather brittle, since there's lots of mocking :(
*/
@Test
public void after_hooks_execute_before_objects_are_disposed() throws Throwable {
Backend backend = mock(Backend.class);
HookDefinition hook = mock(HookDefinition.class);
when(hook.matches(anyListOf(Tag.class))).thenReturn(true);
gherkin.formatter.model.Scenario gherkinScenario = mock(gherkin.formatter.model.Scenario.class);
CucumberFeature feature = mock(CucumberFeature.class);
Feature gherkinFeature = mock(Feature.class);
when(feature.getGherkinFeature()).thenReturn(gherkinFeature);
when(gherkinFeature.getTags()).thenReturn(new ArrayList<Tag>());
CucumberScenario scenario = new CucumberScenario(feature, null, gherkinScenario);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
RuntimeOptions runtimeOptions = new RuntimeOptions("");
Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, asList(backend), runtimeOptions);
runtime.getGlue().addAfterHook(hook);
scenario.run(mock(Formatter.class), mock(Reporter.class), runtime);
InOrder inOrder = inOrder(hook, backend);
inOrder.verify(hook).execute(Matchers.<Scenario>any());
inOrder.verify(backend).disposeWorld();
}
use of gherkin.formatter.model.Tag in project cucumber-jvm by cucumber.
the class RhinoHooksTest method assertHook.
private void assertHook(HookDefinition hookDefinition, String[] tagExprs, int order, long timeoutMillis) {
assertThat(hookDefinition, instanceOf(RhinoHookDefinition.class));
RhinoHookDefinition rhinoHook = (RhinoHookDefinition) hookDefinition;
List<Tag> tags = new ArrayList<Tag>();
for (String tagExpr : tagExprs) {
tags.add(new Tag(tagExpr, null));
}
assertTrue(rhinoHook.getTagExpression().evaluate(tags));
assertThat(rhinoHook.getOrder(), equalTo(order));
assertThat(rhinoHook.getTimeout(), equalTo(timeoutMillis));
}
use of gherkin.formatter.model.Tag in project cucumber-jvm by cucumber.
the class JavaStepDefinitionTest method throws_ambiguous_when_two_matches_are_found.
@Test
public void throws_ambiguous_when_two_matches_are_found() throws Throwable {
backend.addStepDefinition(THREE_DISABLED_MICE.getAnnotation(Given.class), THREE_DISABLED_MICE);
backend.addStepDefinition(THREE_BLIND_ANIMALS.getAnnotation(Given.class), THREE_BLIND_ANIMALS);
Reporter reporter = mock(Reporter.class);
runtime.buildBackendWorlds(reporter, Collections.<Tag>emptySet(), mock(Scenario.class));
Tag tag = new Tag("@foo", 0);
runtime.runBeforeHooks(reporter, asSet(tag));
runtime.runStep("some.feature", new Step(NO_COMMENTS, "Given ", "three blind mice", 1, null, null), reporter, ENGLISH);
ArgumentCaptor<Result> result = ArgumentCaptor.forClass(Result.class);
verify(reporter).result(result.capture());
assertEquals(AmbiguousStepDefinitionsException.class, result.getValue().getError().getClass());
}
Aggregations