Search in sources :

Example 1 with Feature

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

the class JUnitReporterTest method forward_calls_to_formatter_interface_methods.

@Test
public void forward_calls_to_formatter_interface_methods() throws Exception {
    String uri = "uri";
    Feature feature = mock(Feature.class);
    Background background = mock(Background.class);
    ScenarioOutline scenarioOutline = mock(ScenarioOutline.class);
    Examples examples = mock(Examples.class);
    Scenario scenario = mock(Scenario.class);
    Step step = mock(Step.class);
    Formatter formatter = mock(Formatter.class);
    jUnitReporter = new JUnitReporter(mock(Reporter.class), formatter, false, new JUnitOptions(Collections.<String>emptyList()));
    jUnitReporter.uri(uri);
    jUnitReporter.feature(feature);
    jUnitReporter.scenarioOutline(scenarioOutline);
    jUnitReporter.examples(examples);
    jUnitReporter.startOfScenarioLifeCycle(scenario);
    jUnitReporter.background(background);
    jUnitReporter.scenario(scenario);
    jUnitReporter.step(step);
    jUnitReporter.endOfScenarioLifeCycle(scenario);
    jUnitReporter.eof();
    jUnitReporter.done();
    jUnitReporter.close();
    verify(formatter).uri(uri);
    verify(formatter).feature(feature);
    verify(formatter).scenarioOutline(scenarioOutline);
    verify(formatter).examples(examples);
    verify(formatter).startOfScenarioLifeCycle(scenario);
    ;
    verify(formatter).background(background);
    verify(formatter).scenario(scenario);
    verify(formatter).step(step);
    verify(formatter).endOfScenarioLifeCycle(scenario);
    verify(formatter).eof();
    verify(formatter).done();
    verify(formatter).close();
}
Also used : Background(gherkin.formatter.model.Background) ScenarioOutline(gherkin.formatter.model.ScenarioOutline) Formatter(gherkin.formatter.Formatter) Step(gherkin.formatter.model.Step) Feature(gherkin.formatter.model.Feature) Examples(gherkin.formatter.model.Examples) Scenario(gherkin.formatter.model.Scenario) Test(org.junit.Test)

Example 2 with Feature

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

the class CucumberExamplesTest method should_create_example_scenarios.

@Test
public void should_create_example_scenarios() {
    CucumberFeature cucumberFeature = new CucumberFeature(new Feature(COMMENTS, FEATURE_TAGS, "Feature", "", "", 2, "fid"), "f.feature");
    ScenarioOutline so = new ScenarioOutline(COMMENTS, SO_TAGS, "Scenario Outline", "", "", 4, "");
    CucumberScenarioOutline cso = new CucumberScenarioOutline(cucumberFeature, null, so);
    cso.step(new Step(COMMENTS, "Given ", "I have 5 <what> in my <where>", 5, null, null));
    Examples examples = new Examples(COMMENTS, E_TAGS, "Examples", "", "", 6, "", asList(new ExamplesTableRow(COMMENTS, asList("what", "where"), 7, ""), new ExamplesTableRow(COMMENTS, asList("cukes", "belly"), 8, ""), new ExamplesTableRow(COMMENTS, asList("apples", "basket"), 9, "")));
    CucumberExamples cucumberExamples = new CucumberExamples(cso, examples);
    List<CucumberScenario> exampleScenarios = cucumberExamples.createExampleScenarios();
    assertEquals(2, exampleScenarios.size());
    Set<Tag> expectedTags = new HashSet<Tag>();
    expectedTags.addAll(FEATURE_TAGS);
    expectedTags.addAll(SO_TAGS);
    expectedTags.addAll(E_TAGS);
    assertEquals(expectedTags, exampleScenarios.get(0).tagsAndInheritedTags());
    CucumberScenario cucumberScenario = exampleScenarios.get(0);
    Step step = cucumberScenario.getSteps().get(0);
    assertEquals("I have 5 cukes in my belly", step.getName());
}
Also used : Step(gherkin.formatter.model.Step) Feature(gherkin.formatter.model.Feature) ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) ScenarioOutline(gherkin.formatter.model.ScenarioOutline) Tag(gherkin.formatter.model.Tag) Examples(gherkin.formatter.model.Examples) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with Feature

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

the class JUnitFormatterTest method feature.

private Feature feature(String featureName) {
    Feature feature = mock(Feature.class);
    when(feature.getName()).thenReturn(featureName);
    return feature;
}
Also used : Feature(gherkin.formatter.model.Feature) CucumberFeature(cucumber.runtime.model.CucumberFeature)

Example 4 with Feature

use of gherkin.formatter.model.Feature 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();
}
Also used : InOrder(org.mockito.InOrder) Formatter(gherkin.formatter.Formatter) Reporter(gherkin.formatter.Reporter) CucumberScenario(cucumber.runtime.model.CucumberScenario) CucumberFeature(cucumber.runtime.model.CucumberFeature) Feature(gherkin.formatter.model.Feature) CucumberFeature(cucumber.runtime.model.CucumberFeature) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) Tag(gherkin.formatter.model.Tag) Test(org.junit.Test)

Aggregations

Feature (gherkin.formatter.model.Feature)4 Test (org.junit.Test)3 CucumberFeature (cucumber.runtime.model.CucumberFeature)2 Formatter (gherkin.formatter.Formatter)2 Examples (gherkin.formatter.model.Examples)2 ScenarioOutline (gherkin.formatter.model.ScenarioOutline)2 Step (gherkin.formatter.model.Step)2 Tag (gherkin.formatter.model.Tag)2 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)1 CucumberScenario (cucumber.runtime.model.CucumberScenario)1 Reporter (gherkin.formatter.Reporter)1 Background (gherkin.formatter.model.Background)1 ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)1 Scenario (gherkin.formatter.model.Scenario)1 HashSet (java.util.HashSet)1 InOrder (org.mockito.InOrder)1