Support (groovy) method names with spaces
See original GitHub issueGroovy allows method names with spaces and other special chars, like this here:
@Given("")
void "ein Benutzer ist als Admin mit dem Benutzernamen {string} angemeldet"(String userMail) {
final def adminEmail = getProperty(userMail);
}
This would allow us to use the actual step definition string as the method name, instead of artificial/weird method names.
This could easily be supported by adding this “fix” to the JavaStepDefinition
class. Instead of failing if the annotation value is empty, it could do this:
if (expression != null && !"".intern().equals(expression)) {
this.expression = requireNonNull(expression, "cucumber-expression may not be null");
} else {
// groovy methods can be strings, so in case the expression is empty, we just use the method name
this.expression = method.getName();
}
Possibly combined with a check if the class implements GroovyObject
.
Additionally it would be nice to set the annotation default values to an empty string, so that @Given("")
could be further reduced to @Given
.
With such a small code change groovy support could be drastically improved (even without a separate backend!).
I tried this myself (created a new groovy backend) but failed because both the java and my groovy backend matched the same step definitions leading to duplication exceptions.
Hope you guys are open for such improvements 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
I’m not really interested in maintaining an exception and associated tests for Groovy.
Each backend should use its own annotations/methods and through the
ObjectFactory
each backend also has access to the same test context. There should be very little conflict.This issue has been automatically closed because of inactivity. You can support the Cucumber core team on opencollective.