Search in sources :

Example 1 with CucumberScenarioOutline

use of cucumber.runtime.model.CucumberScenarioOutline 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 CucumberScenarioOutline

use of cucumber.runtime.model.CucumberScenarioOutline in project cucumber-jvm by cucumber.

the class FeatureRunner method buildFeatureElementRunners.

private void buildFeatureElementRunners() {
    for (CucumberTagStatement cucumberTagStatement : cucumberFeature.getFeatureElements()) {
        try {
            ParentRunner featureElementRunner;
            if (cucumberTagStatement instanceof CucumberScenario) {
                featureElementRunner = new ExecutionUnitRunner(runtime, (CucumberScenario) cucumberTagStatement, jUnitReporter);
            } else {
                featureElementRunner = new ScenarioOutlineRunner(runtime, (CucumberScenarioOutline) cucumberTagStatement, jUnitReporter);
            }
            children.add(featureElementRunner);
        } catch (InitializationError e) {
            throw new CucumberException("Failed to create scenario runner", e);
        }
    }
}
Also used : CucumberScenarioOutline(cucumber.runtime.model.CucumberScenarioOutline) InitializationError(org.junit.runners.model.InitializationError) CucumberScenario(cucumber.runtime.model.CucumberScenario) CucumberTagStatement(cucumber.runtime.model.CucumberTagStatement) CucumberException(cucumber.runtime.CucumberException) ParentRunner(org.junit.runners.ParentRunner)

Aggregations

CucumberScenarioOutline (cucumber.runtime.model.CucumberScenarioOutline)2 CucumberTagStatement (cucumber.runtime.model.CucumberTagStatement)2 CucumberException (cucumber.runtime.CucumberException)1 CucumberExamples (cucumber.runtime.model.CucumberExamples)1 CucumberFeature (cucumber.runtime.model.CucumberFeature)1 CucumberScenario (cucumber.runtime.model.CucumberScenario)1 Examples (gherkin.formatter.model.Examples)1 ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)1 ArrayList (java.util.ArrayList)1 ParentRunner (org.junit.runners.ParentRunner)1 InitializationError (org.junit.runners.model.InitializationError)1