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;
}
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();
}
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());
}
Aggregations