Add error check to scenario outline, add java snippet escaping for + and . #596

merged 3 commits into from Oct 12, 2013


None yet
2 participants

guyburton commented Sep 26, 2013

There is an issue that a step such as Given < some data > 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
public void outlineReferenceWithNoOtherTextAndNoValueCausesException() {
    List<DataTableRow> rows = asList(new DataTableRow(NO_COMMENTS, asList("", ""), 1));
    Step outlineStep = new Step(NO_COMMENTS, "Given ", "<reference>", 0, rows, null);

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

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

aslakhellesoy added a commit that referenced this pull request Oct 12, 2013

@aslakhellesoy aslakhellesoy merged commit a280f2f into cucumber:master Oct 12, 2013

1 check passed

default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment