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

Error when passing empty table to step #1912

Closed
john-caleb-phillips opened this issue Mar 4, 2020 · 1 comment · Fixed by #1913
Closed

Error when passing empty table to step #1912

john-caleb-phillips opened this issue Mar 4, 2020 · 1 comment · Fixed by #1913
Labels
🐛 bug Defect / Bug

Comments

@john-caleb-phillips
Copy link

john-caleb-phillips commented Mar 4, 2020

My project was recently upgraded to Cucumber 5 from Cucumber 4, and we are having a regression when attempting to pass an empty list to a step.

I have a step like the following:

@Then("I see only the following buttons:")
public void validateButtons(List buttonNames) {
    // Check for the buttons
}

Importantly, this step throws an error if there are unexpected buttons. So, we use it to both ensure the presence of expected buttons, and the invisibility of other buttons. For example, we use it to make sure that there is not an "Edit" button for certain users, like so:

Then I see only the following buttons:
  | Send Record for Approval | Validate Record |

However, sometimes we need to validate that there are no buttons on the page. To make that happen we would call the step like so:

Then I see the following buttons:
  | 

This would then pass an empty list to the step.
After upgrading to Cucumber 5, scenarios that are passing the empty list are failing when attempting to initialize the runner class with the following error:

RunnerClass.initializationError  Time elapsed: 0.012 s  <<< ERROR!
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0

I've checked through the code, and the issue appears to be that when the constructor of GherkinVintageDataTableArgument is called, it calls the getLocation() method from PickleTable, and this method just returns the getLocation() method from PickleCell. Since there are no cells in this situation, the error is thrown.

I recognize that passing an empty table to a step might not be something that you want to support. But it was something that was allowed earlier, and I'd appreciate it if there is some way to allow it again.

@mpkorstanje
Copy link
Contributor

As ugly as it looks, the parser accepts it so the feature file is valid. This will be fixed with #1913.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants