Skip to content
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

gherkin: StringIndexOutOfBoundsException in step #396

Closed
Bludwarf opened this issue May 24, 2018 · 3 comments
Closed

gherkin: StringIndexOutOfBoundsException in step #396

Bludwarf opened this issue May 24, 2018 · 3 comments

Comments

@Bludwarf
Copy link

Summary

Including capturing groups in another one in a step annotation RegExp makes cucumber throws StringIndexOutOfBoundsException.

Expected Behavior

Parse this line of cucumber :

Then reset x table on y except z

Where the except part is optionnal

Current Behavior

The line is well executed by cucumber but at the end of the feature (or after the end) it throws this exception :

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.041 sec <<< FAILURE! - in 
[...]
java.lang.StringIndexOutOfBoundsException: String index out of range: -Z

Where Z is the length of the parameter except

Possible Solution

Create a glue method like this :

@Given("reset (.+) table on ([A-Za-z_-]+)(?: except (.+))?")
public void doResetTableWithExcept(String table, String schema, String except) throws SQLException {

This way except keyword is not in a capturing group and makes cucumber work.

Steps to Reproduce (for bugs)

Create a glue method like this :

@Given("reset (.+) table on ([A-Za-z_-]+)( except (.+))?")
public void doResetTableWithExcept(String table, String schema, String exceptPart, String except) throws SQLException {

This way except keyword is in a capturing group and makes cucumber throw the exception.

Context & Motivation

Your Environment

  • Version used: 1.2.5
  • Operating System and version: Windows 10
  • Link to your project: (private)

pom.xml extract :

    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-java</artifactId>
      <version>1.2.5</version>
    </dependency>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-spring</artifactId>
      <version>1.2.5</version>
    </dependency>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-junit</artifactId>
      <version>1.2.5</version>
    </dependency>
@mlvandijk
Copy link
Member

mlvandijk commented May 24, 2018

@Bludwarf Please note you're using an old version of Cucumber. Try upgrading to a newer version. (Currently at v3.0.0 - which is not even a week old). Note that the <groupId>info.cukes</groupId> was changed to <groupId>io.cucumber</groupId> as of v2.0.0

Also, afaik this was fixed, see: cucumber/cucumber-jvm#1200 which is part of v2.0.0 and up (see changelog)

@mlvandijk
Copy link
Member

Closing this issue, feel free to reopen if upgrading to v2.0.0 or higher doesn't fix it.

@lock
Copy link

lock bot commented May 24, 2019

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 May 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants