Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 12, 2013

Conversation

guyburton
Copy link
Contributor

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
@Test
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(
            outlineStep,
            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
@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants