Skip to content

Commit

Permalink
Merge #580. Update History.md
Browse files Browse the repository at this point in the history
  • Loading branch information
brasmusson committed Sep 3, 2013
2 parents 1e917e1 + 12e0223 commit 89982ea
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions History.md
@@ -1,5 +1,6 @@
## [1-1-5-SNAPSHOT (Git master)](https://github.com/cucumber/cucumber-jvm/compare/v1.1.4...master)

* [Core] Replace placeholders in the Scenario Outline title ([#580](https://github.com/cucumber/cucumber-jvm/pull/580), [#510](https://github.com/cucumber/cucumber-jvm/issues/510) Jamie W. Astin)
* [JUnit/Core] `@cucumber.junit.api.Cucumber.Options` is deprecated in favour of `@cucumber.api.Options` ([#549](https://github.com/cucumber/cucumber-jvm/issues/549) Aslak Hellesøy)
* [JUnit] Inherit Information of @Cucumber.Options ([#568](https://github.com/cucumber/cucumber-jvm/issues/568) Klaus Bayrhammer)
* [JUnit] JUnitFormatter does not put required name attribute in testsuite root element ([#480](https://github.com/cucumber/cucumber-jvm/pull/480), [#477](https://github.com/cucumber/cucumber-jvm/issues/477) ericmaxwell2003)
Expand Down
Expand Up @@ -48,7 +48,10 @@ public void run(Formatter formatter, Reporter reporter, Runtime runtime) {
}

CucumberScenario createExampleScenario(ExamplesTableRow header, ExamplesTableRow example, List<Tag> examplesTags) {
Scenario exampleScenario = new Scenario(example.getComments(), examplesTags, getGherkinModel().getKeyword(), getGherkinModel().getName(), "", example.getLine(), example.getId());
// Make sure we replace the tokens in the name of the scenario
String exampleScenarioName = replaceTokens(new HashSet<Integer>(), header.getCells(), example.getCells(), getGherkinModel().getName());

Scenario exampleScenario = new Scenario(example.getComments(), examplesTags, getGherkinModel().getKeyword(), exampleScenarioName, "", example.getLine(), example.getId());
CucumberScenario cucumberScenario = new CucumberScenario(cucumberFeature, cucumberBackground, exampleScenario, example);
for (Step step : getSteps()) {
cucumberScenario.step(createExampleStep(step, header, example));
Expand Down
Expand Up @@ -4,17 +4,21 @@
import gherkin.formatter.model.DataTableRow;
import gherkin.formatter.model.DocString;
import gherkin.formatter.model.ExamplesTableRow;
import gherkin.formatter.model.ScenarioOutline;
import gherkin.formatter.model.Step;
import gherkin.formatter.model.Tag;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;

public class CucumberScenarioOutlineTest {
private static final List<Comment> C = new ArrayList<Comment>();
private static final List<Tag> T = Collections.<Tag>emptyList();

@Test
public void replaces_tokens_in_step_names() {
Expand All @@ -38,5 +42,41 @@ public void replaces_tokens_in_data_tables() {

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

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

0 comments on commit 89982ea

Please sign in to comment.