Search in sources :

Example 6 with ExamplesTableRow

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

the class CucumberScenarioOutlineTest method replaces_tokens_in_scenario_names.

/***
     * From a scenario outline, we create one or more "Example Scenario"s. This is composed
     * of each step from the outline, with the tokens replaced with the pertient values 
     * for the current example row. <p />
     * 
     * Each "Example Scenario" has a name. This was previously just a copy of the outline's
     * name. However, we'd like to be able to support token replacement in the scenario too,
     * for example:
     * 
     * <pre>
     * Scenario Outline: Time offset check for <LOCATION_NAME>
     * Given my local country is <LOCATION_NAME>
     * When I compare the time difference to GMT
     * Then the time offset should be <OFFSET>
     *  
     * Examples: 
     * | LOCATION_NAME | OFFSET |
     * | London        | 1      |
     * | San Fran      | 8      |
     * </pre>
     * 
     * Will create a scenario named "Time offset check for London" for the first row in the 
     * examples table.
     */
@Test
public void replaces_tokens_in_scenario_names() {
    // Create Gherkin the outline itself ...
    ScenarioOutline outline = new ScenarioOutline(C, T, "Scenario Outline", "Time offset check for <LOCATION_NAME>", "", new Integer(1), "");
    // ... then the Cukes implementation
    CucumberScenarioOutline cukeOutline = new CucumberScenarioOutline(null, null, outline);
    CucumberScenario exampleScenario = cukeOutline.createExampleScenario(new ExamplesTableRow(C, asList("LOCATION_NAME"), 1, ""), new ExamplesTableRow(C, asList("London"), 1, ""), T, "");
    assertEquals("Time offset check for London", exampleScenario.getGherkinModel().getName());
}
Also used : ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) ScenarioOutline(gherkin.formatter.model.ScenarioOutline) Test(org.junit.Test)

Example 7 with ExamplesTableRow

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

the class CucumberScenarioOutlineTest method replaces_tokens_in_step_names.

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

Example 8 with ExamplesTableRow

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

the class CucumberScenarioOutlineTest method allows_doc_strings_to_be_empty_after_replacement.

@Test
public void allows_doc_strings_to_be_empty_after_replacement() {
    Step outlineStep = new Step(C, null, "Some step", 0, null, new DocString(null, "<doc string>", 1));
    Step exampleStep = CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("doc string"), 1, ""), new ExamplesTableRow(C, asList(""), 1, ""));
    assertEquals("", exampleStep.getDocString().getValue());
}
Also used : ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) DocString(gherkin.formatter.model.DocString) 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