Search in sources :

Example 1 with Examples

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

the class ScenarioCounterTest method createCucumberFeaturesWithScenarioOutlines.

private List<CucumberFeature> createCucumberFeaturesWithScenarioOutlines(final int numberOfCucumberFeatures, final int numberOfScenarioOutlines, final int numberOfCucumberExamples, final int numberOfExampleRows) {
    final int numberOfExampleRowsIncludingHeaderRow = numberOfExampleRows + 1;
    final List<CucumberFeature> cucumberFeatures = new ArrayList<CucumberFeature>();
    for (int f = 0; f < numberOfCucumberFeatures; f++) {
        final CucumberFeature cucumberFeature = mock(CucumberFeature.class);
        cucumberFeatures.add(cucumberFeature);
        // set up 2 scenarios outlines
        final List<CucumberTagStatement> cucumberTagStatements = new ArrayList<CucumberTagStatement>();
        for (int o = 0; o < numberOfScenarioOutlines; o++) {
            cucumberTagStatements.add(mock(CucumberScenarioOutline.class));
        }
        when(cucumberFeature.getFeatureElements()).thenReturn(cucumberTagStatements);
        // with 2 examples for each scenario outline
        for (final CucumberTagStatement cucumberTagStatement : cucumberTagStatements) {
            final CucumberScenarioOutline cucumberScenarioOutline = (CucumberScenarioOutline) cucumberTagStatement;
            final List<CucumberExamples> cucumberExamplesList = createMockList(CucumberExamples.class, numberOfCucumberExamples);
            when(cucumberScenarioOutline.getCucumberExamplesList()).thenReturn(cucumberExamplesList);
            // each example should have two rows (excluding the header row)
            for (final CucumberExamples cucumberExamples : cucumberExamplesList) {
                final Examples examples = mock(Examples.class);
                when(examples.getRows()).thenReturn(createMockList(ExamplesTableRow.class, numberOfExampleRowsIncludingHeaderRow));
                when(cucumberExamples.getExamples()).thenReturn(examples);
            }
        }
    }
    return cucumberFeatures;
}
Also used : CucumberScenarioOutline(cucumber.runtime.model.CucumberScenarioOutline) ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) CucumberFeature(cucumber.runtime.model.CucumberFeature) ArrayList(java.util.ArrayList) CucumberTagStatement(cucumber.runtime.model.CucumberTagStatement) CucumberExamples(cucumber.runtime.model.CucumberExamples) CucumberExamples(cucumber.runtime.model.CucumberExamples) Examples(gherkin.formatter.model.Examples)

Example 2 with Examples

use of gherkin.formatter.model.Examples 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 3 with Examples

use of gherkin.formatter.model.Examples 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)

Aggregations

Examples (gherkin.formatter.model.Examples)3 ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)2 Feature (gherkin.formatter.model.Feature)2 ScenarioOutline (gherkin.formatter.model.ScenarioOutline)2 Step (gherkin.formatter.model.Step)2 Test (org.junit.Test)2 CucumberExamples (cucumber.runtime.model.CucumberExamples)1 CucumberFeature (cucumber.runtime.model.CucumberFeature)1 CucumberScenarioOutline (cucumber.runtime.model.CucumberScenarioOutline)1 CucumberTagStatement (cucumber.runtime.model.CucumberTagStatement)1 Formatter (gherkin.formatter.Formatter)1 Background (gherkin.formatter.model.Background)1 Scenario (gherkin.formatter.model.Scenario)1 Tag (gherkin.formatter.model.Tag)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1