All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cucumber.runtime.model.CucumberExamples Maven / Gradle / Ivy

There is a newer version: 1.2.6
Show newest version
package cucumber.runtime.model;

import gherkin.formatter.Formatter;
import gherkin.formatter.model.Examples;
import gherkin.formatter.model.ExamplesTableRow;
import gherkin.formatter.model.Tag;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class CucumberExamples {
    private final CucumberScenarioOutline cucumberScenarioOutline;
    private final Examples examples;

    public CucumberExamples(CucumberScenarioOutline cucumberScenarioOutline, Examples examples) {
        this.cucumberScenarioOutline = cucumberScenarioOutline;
        this.examples = examples;
    }

    public List createExampleScenarios() {
        List exampleScenarios = new ArrayList();

        List rows = examples.getRows();
        List tags = new ArrayList(tagsAndInheritedTags());
        for (int i = 1; i < rows.size(); i++) {
            exampleScenarios.add(cucumberScenarioOutline.createExampleScenario(rows.get(0), rows.get(i), tags));
        }
        return exampleScenarios;
    }

    private Set tagsAndInheritedTags() {
        Set tags = new HashSet();
        tags.addAll(cucumberScenarioOutline.tagsAndInheritedTags());
        tags.addAll(examples.getTags());
        return tags;
    }

    public Examples getExamples() {
        return examples;
    }

    public void format(Formatter formatter) {
        examples.replay(formatter);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy