Search in sources :

Example 1 with Tag

use of gherkin.formatter.model.Tag in project cucumber-jvm by cucumber.

the class HookOrderTest method before_hooks_execute_in_order.

@Test
public void before_hooks_execute_in_order() throws Throwable {
    List<HookDefinition> hooks = mockHooks(3, Integer.MAX_VALUE, 1, -1, 0, 10000, Integer.MIN_VALUE);
    for (HookDefinition hook : hooks) {
        glue.addBeforeHook(hook);
    }
    runtime.runBeforeHooks(mock(Reporter.class), new HashSet<Tag>());
    InOrder inOrder = inOrder(hooks.toArray());
    inOrder.verify(hooks.get(6)).execute(Matchers.<Scenario>any());
    inOrder.verify(hooks.get(3)).execute(Matchers.<Scenario>any());
    inOrder.verify(hooks.get(4)).execute(Matchers.<Scenario>any());
    inOrder.verify(hooks.get(2)).execute(Matchers.<Scenario>any());
    inOrder.verify(hooks.get(0)).execute(Matchers.<Scenario>any());
    inOrder.verify(hooks.get(5)).execute(Matchers.<Scenario>any());
    inOrder.verify(hooks.get(1)).execute(Matchers.<Scenario>any());
}
Also used : InOrder(org.mockito.InOrder) Reporter(gherkin.formatter.Reporter) Tag(gherkin.formatter.model.Tag) Test(org.junit.Test)

Example 2 with Tag

use of gherkin.formatter.model.Tag in project cucumber-jvm by cucumber.

the class HookOrderTest method hooks_order_across_many_backends.

@Test
public void hooks_order_across_many_backends() throws Throwable {
    List<HookDefinition> backend1Hooks = mockHooks(3, Integer.MAX_VALUE, 1);
    for (HookDefinition hook : backend1Hooks) {
        glue.addBeforeHook(hook);
    }
    List<HookDefinition> backend2Hooks = mockHooks(2, Integer.MAX_VALUE, 4);
    for (HookDefinition hook : backend2Hooks) {
        glue.addBeforeHook(hook);
    }
    runtime.runBeforeHooks(mock(Reporter.class), new HashSet<Tag>());
    List<HookDefinition> allHooks = new ArrayList<HookDefinition>();
    allHooks.addAll(backend1Hooks);
    allHooks.addAll(backend2Hooks);
    InOrder inOrder = inOrder(allHooks.toArray());
    inOrder.verify(backend1Hooks.get(2)).execute(Matchers.<Scenario>any());
    inOrder.verify(backend2Hooks.get(0)).execute(Matchers.<Scenario>any());
    inOrder.verify(backend1Hooks.get(0)).execute(Matchers.<Scenario>any());
    inOrder.verify(backend2Hooks.get(2)).execute(Matchers.<Scenario>any());
    verify(backend2Hooks.get(1)).execute(Matchers.<Scenario>any());
    verify(backend1Hooks.get(1)).execute(Matchers.<Scenario>any());
}
Also used : InOrder(org.mockito.InOrder) Reporter(gherkin.formatter.Reporter) ArrayList(java.util.ArrayList) Tag(gherkin.formatter.model.Tag) Test(org.junit.Test)

Example 3 with Tag

use of gherkin.formatter.model.Tag in project cucumber-jvm by cucumber.

the class JavaStepDefinitionTest method does_not_throw_ambiguous_when_nothing_is_ambiguous.

@Test
public void does_not_throw_ambiguous_when_nothing_is_ambiguous() throws Throwable {
    backend.addStepDefinition(THREE_DISABLED_MICE.getAnnotation(Given.class), THREE_DISABLED_MICE);
    Reporter reporter = new Reporter() {

        @Override
        public void before(Match match, Result result) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void result(Result result) {
            if (result.getError() != null) {
                throw new RuntimeException(result.getError());
            }
        }

        @Override
        public void after(Match match, Result result) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void match(Match match) {
        }

        @Override
        public void embedding(String mimeType, byte[] data) {
        }

        @Override
        public void write(String text) {
        }
    };
    runtime.buildBackendWorlds(reporter, Collections.<Tag>emptySet(), mock(Scenario.class));
    Tag tag = new Tag("@foo", 0);
    Set<Tag> tags = asSet(tag);
    runtime.runBeforeHooks(reporter, tags);
    Step step = new Step(NO_COMMENTS, "Given ", "three blind mice", 1, null, null);
    runtime.runStep("some.feature", step, reporter, ENGLISH);
    assertTrue(defs.foo);
    assertFalse(defs.bar);
}
Also used : Given(cucumber.api.java.en.Given) Reporter(gherkin.formatter.Reporter) Tag(gherkin.formatter.model.Tag) Step(gherkin.formatter.model.Step) Match(gherkin.formatter.model.Match) Result(gherkin.formatter.model.Result) Scenario(gherkin.formatter.model.Scenario) Test(org.junit.Test)

Example 4 with Tag

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))));
}
Also used : Before(cucumber.api.java.Before) Tag(gherkin.formatter.model.Tag) HookDefinition(cucumber.runtime.HookDefinition) Test(org.junit.Test)

Example 5 with Tag

use of gherkin.formatter.model.Tag in project cucumber-jvm by cucumber.

the class HTMLFormatterTest method runFeaturesWithFormatter.

private void runFeaturesWithFormatter(URL outputDir) throws IOException {
    final HTMLFormatter f = new HTMLFormatter(outputDir);
    f.uri("some\\windows\\path\\some.feature");
    f.scenario(new Scenario(Collections.<Comment>emptyList(), Collections.<Tag>emptyList(), "Scenario", "some cukes", "", 10, "id"));
    f.embedding("image/png", "fakedata".getBytes("US-ASCII"));
    f.embedding("text/plain", "dodgy stack trace here".getBytes("US-ASCII"));
    f.done();
    f.close();
}
Also used : Comment(gherkin.formatter.model.Comment) Tag(gherkin.formatter.model.Tag) Scenario(gherkin.formatter.model.Scenario)

Aggregations

Tag (gherkin.formatter.model.Tag)12 Test (org.junit.Test)9 Reporter (gherkin.formatter.Reporter)6 InOrder (org.mockito.InOrder)4 Scenario (gherkin.formatter.model.Scenario)3 Step (gherkin.formatter.model.Step)3 Before (cucumber.api.java.Before)2 Given (cucumber.api.java.en.Given)2 HookDefinition (cucumber.runtime.HookDefinition)2 Feature (gherkin.formatter.model.Feature)2 Result (gherkin.formatter.model.Result)2 ArrayList (java.util.ArrayList)2 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)1 CucumberFeature (cucumber.runtime.model.CucumberFeature)1 CucumberScenario (cucumber.runtime.model.CucumberScenario)1 Formatter (gherkin.formatter.Formatter)1 Comment (gherkin.formatter.model.Comment)1 Examples (gherkin.formatter.model.Examples)1 ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)1 Match (gherkin.formatter.model.Match)1