cucumber/cucumber-jvm — pull request #596 by guyburton (2013-09-26 22:30:53+00:00)
Title: Add error check to scenario outline, add java snippet escaping for + and .

There is an issue that a step such as Given with a table like
| some data |
| |

will throw an IndexOutOfBoundsException in the UnderscoreFunctionNameSanitizer. The token gets replaced with blank causing the issue. The test case below replicates the issue but I dont suggest adding this to the test suite.

I've added two checks- one in the sanitizer itself, and one in the calling code, which gives a more understandable error message for people who implement the step definition above.

I also added . and + to the list of escaped characters for the regex pattern generation since these were missing and added a test case for the UnderscoreFunctionNameSanitizer.

// throws IndexOutOfBoundsException
@Test
public void outlineReferenceWithNoOtherTextAndNoValueCausesException() {
List rows = asList(new DataTableRow(NO_COMMENTS, asList("", ""), 1));
Step outlineStep = new Step(NO_COMMENTS, "Given ", "", 0, rows, null);

Step step = CucumberScenarioOutline.createExampleStep(
outlineStep,
new ExamplesTableRow(NO_COMMENTS, asList("reference"), 1, ""), // header
new ExamplesTableRow(NO_COMMENTS, asList(""), 1, "")); // data

new SnippetGenerator(new JavaSnippet()).getSnippet(step, new UnderscoreFunctionNameSanitizer());
}