I'm having a problem with setting up the developing environment of my own. I'm using eclipse phontom with eclipse-groovy
and Cucumber Eclipse plugin
, and want to join the development that write test codes using groovy and cucumber.
At first I import dependency for cucumber (io.cucumber.cucumber-groovy:4.5.3
) through maven , and everything works fine. However, some days later, colleagues had told me that they used to import dependency with older version (info.cukes.cucumber-groovy:1.2.4
). And everything is broken in my laptop after downgrade.
For example, following is a simple step definition of Given
.
package steps
import cucumber.api.groovy.EN
import cucumber.api.groovy.Hooks
this.metaClass.mixin(EN)
this.metaClass.mixin(Hooks)
Given(/an item ID which does not exist/) { ->
documentId = "test_not_exist_" + UUID.randomUUID().toString()
}
And when I run it on my laptop, the following exception is raised.
No signature of method: steps.RawItemRetrieval.Given() is applicable for argument types: (java.lang.String, steps.RawItemRetrieval$_run_closure1) values: [an item ID which does not exist, steps.RawItemRetrieval$_run_closure1@45d2ade3]
Possible solutions: grep(), run(), run(), find(), every()
at cucumber.runtime.groovy.GroovyBackend.loadGlue(GroovyBackend.java:85)
at cucumber.runtime.Runtime.<init>(Runtime.java:91)
at cucumber.runtime.Runtime.<init>(Runtime.java:69)
at cucumber.runtime.Runtime.<init>(Runtime.java:65)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main.main(Main.java:18)
Is there anything I should do to make things work under dependency info.cukes.cucumber-groovy:1.2.4
?
Following are my development environment which may be relevant:
JDK: Amazon Corretto-8.212.04.2 (build 1.8.0_212-b04)
Maven: 3.3.9
Groovy compiler in eclipse: 2.4.17
Any suggestions would be appreciated. Thanks!
OK, I think I have found the reason. Maybe it is caused by cucumber 1.2.4 does not support step definition in the following format:
Given(/an item ID which does not exist/) { ->
....
}
When I change the style to regex format, it works again.
Given(~/^an item ID which does not exist$/) { ->
....
}
Thanks Mark Rotteveel for the suggestion!