Description
Groovy 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 :-)