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