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
"The gherkin step has 0 arguments" while there is one argument #515
Comments
It looks to me like you are mixing cucumber expressions and regex. Could you please try replacing (\d+) with {int}? |
@mlvandijk Thank you- {int} works. At the same I think that (\d+) should also work, acording to https://docs.cucumber.io/cucumber/cucumber-expressions/ ("You can use Regular Expressions or Cucumber Expressions."). |
@tomaszwojciechowski Yes, but in that case you need to start your String with ^ and end with $, like this: |
@mlvandijk Thank you. |
We're using some simple using heuristics in ExpressionFactory.java to determine if an expression string should be interpreted as a CucumberExpression or a RegularExpression. It sounds like these heuristics could be improved. I'd be very grateful if you submitted a pull request to improve this @tomaszwojciechowski! It's a nice, small problem to work on. |
Explaining when a string is interpreted as a cucumber expression should be rather straight forward. In essence the explanation should be: If you surround a string with `^` and `$` it will be a regular expression. If not, it is a cucumber expression. However the heuristic complicates this by checking if a capture group contains regular expression symbols `[]+.*` with the assumption that these are not used in normal writing. This allows us to write little marvels like: this looks\( i.e: no regex symbols) like a cukexp a heavy storm forecast \(BF {int}+) the temperature is (\+){int} degrees celsius Which look deceptively like cucumber expressions but are in fact regular expressions. Simplifying the heuristic remove this ambiguity. This does comes at the cost of being able to recognize obvious regular expressions. this (.+) like a regexp this (\d+) like a regexp this ([a-z]+) like a regexp But I think the simplicity is worth it. Related: * cucumber/cucumber-jvm#1581 * #515
Isn't it possible to mix regular expressions and cucumber expressions? |
It is not no. You need to use one or the other. Because the characters mean different things in the different constructs. I.e. |
Explaining when a string is interpreted as a cucumber expression should be rather straight forward. In essence the explanation should be: If you surround a string with `^` and `$` it will be a regular expression. If not, it is a cucumber expression. However the heuristic complicates this by checking if a capture group contains regular expression symbols `[]+.*` with the assumption that these are not used in normal writing. This allows us to write little marvels like: this looks\( i.e: no regex symbols) like a cukexp a heavy storm forecast \(BF {int}+) the temperature is (\+){int} degrees celsius Which look deceptively like cucumber expressions but are in fact regular expressions. Simplifying the heuristic remove this ambiguity. This does comes at the cost of being able to recognize obvious regular expressions. this (.+) like a regexp this (\d+) like a regexp this ([a-z]+) like a regexp But I think the simplicity is worth it. Related: * cucumber/cucumber-jvm#1581 * cucumber/common#515
In .feature I've:
When I wait for 2 seconds
,Cucumber expression:
@And("I wait for (\\d+) seconds")
.For test execution I get: "the gherkin step has 0 arguments".
The text was updated successfully, but these errors were encountered: