Search in sources :

Example 1 with ExamplesTableRow

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

the class CucumberScenarioOutlineTest method replaces_tokens_in_data_tables.

@Test
public void replaces_tokens_in_data_tables() {
    List<DataTableRow> rows = asList(new DataTableRow(C, asList("I", "have <n> cukes"), 1));
    Step outlineStep = new Step(C, null, "I have <n> cukes", 0, rows, null);
    Step exampleStep = CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("n"), 1, ""), new ExamplesTableRow(C, asList("10"), 1, ""));
    assertEquals(asList("I", "have 10 cukes"), exampleStep.getRows().get(0).getCells());
}
Also used : ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) Step(gherkin.formatter.model.Step) DataTableRow(gherkin.formatter.model.DataTableRow) Test(org.junit.Test)

Example 2 with ExamplesTableRow

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

the class CucumberScenarioOutlineTest method replaces_tokens_in_doc_strings.

@Test
public void replaces_tokens_in_doc_strings() {
    Step outlineStep = new Step(C, null, "I have <n> cukes", 0, null, new DocString(null, "I have <n> cukes", 1));
    Step exampleStep = CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("n"), 1, ""), new ExamplesTableRow(C, asList("10"), 1, ""));
    assertEquals("I have 10 cukes", exampleStep.getDocString().getValue());
}
Also used : ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) DocString(gherkin.formatter.model.DocString) Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Example 3 with ExamplesTableRow

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

the class CucumberScenarioOutlineTest method allows_data_table_entries_to_be_empty_after_replacement.

@Test
public void allows_data_table_entries_to_be_empty_after_replacement() {
    List<DataTableRow> rows = asList(new DataTableRow(C, asList("<entry>"), 1));
    Step outlineStep = new Step(C, null, "Some step", 0, rows, null);
    Step exampleStep = CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("entry"), 1, ""), new ExamplesTableRow(C, asList(""), 1, ""));
    assertEquals(asList(""), exampleStep.getRows().get(0).getCells());
}
Also used : ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) Step(gherkin.formatter.model.Step) DataTableRow(gherkin.formatter.model.DataTableRow) Test(org.junit.Test)

Example 4 with ExamplesTableRow

use of gherkin.formatter.model.ExamplesTableRow 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 5 with ExamplesTableRow

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

the class CucumberScenarioOutlineTest method does_not_allow_the_step_to_be_empty_after_replacement.

@Test(expected = CucumberException.class)
public void does_not_allow_the_step_to_be_empty_after_replacement() {
    Step outlineStep = new Step(C, null, "<step>", 0, null, null);
    CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("step"), 1, ""), new ExamplesTableRow(C, asList(""), 1, ""));
}
Also used : ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Aggregations

ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)8 Test (org.junit.Test)8 Step (gherkin.formatter.model.Step)7 DataTableRow (gherkin.formatter.model.DataTableRow)2 DocString (gherkin.formatter.model.DocString)2 ScenarioOutline (gherkin.formatter.model.ScenarioOutline)2 Examples (gherkin.formatter.model.Examples)1 Feature (gherkin.formatter.model.Feature)1 Tag (gherkin.formatter.model.Tag)1 HashSet (java.util.HashSet)1