Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error running Cucumber Geb tests in IntelliJ IDE using groovy

I am getting following error when running Geb tests in IntelliJ IDE.

org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: features.step_definitions.MyHomeStepDef.to() is applicable for argument types: (java.lang.Class) values: [class geb.pages.MyLandingPage]
Possible solutions: is(java.lang.Object), run(), run(), any(), any(groovy.lang.Closure), with(groovy.lang.Closure)
  at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:97)
  at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
  at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:904)
  at groovy.lang.Closure.call(Closure.java:415)
  at cucumber.runtime.groovy.GroovyBackend.invoke(GroovyBackend.java:133)
  at cucumber.runtime.groovy.GroovyStepDefinition.execute(GroovyStepDefinition.java:48)
  at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:45)
  at cucumber.runtime.Runtime.runStep(Runtime.java:248)
  ...
  at cucumber.cli.Main.main(Main.java:12)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  at ✽.Given I am on the My home page(D:\MyFolder\src\test\resources\features\my-login-page.feature:5)
Caused by: groovy.lang.MissingMethodException: No signature of method: features.step_definitions.MyHomeStepDef.to() is applicable for argument types: (java.lang.Class) values: [class geb.pages.MyLandingPage]
Possible solutions: is(java.lang.Object), run(), run(), any(), any(groovy.lang.Closure), with(groovy.lang.Closure)
  at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
  at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:78)
  at features.step_definitions.MyHomeStepDef$_run_closure1.doCall(MyHomeStepDef.groovy:25)
  .....
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Error occurred in the step definition file when try to access the web page via Geb

Given(~'^I am on the My home page$') { ->

    to MyLandingPage
    waitFor { at(MyLandingPage) }
}

Tests are running perfectly in command-line with gradle test command

like image 913
SMPH Avatar asked Nov 10 '22 02:11

SMPH


1 Answers

I had the same issue and finally found a solution. Based on the sample project https://github.com/geb/geb-example-cucumber-jvm.git you need to make sure the file 'env.groovy' is also referenced in the glue list in the run configuration. cucumber-java settings Then the BindingUpdater is loaded correctly and all the geb specific methods are available in the steps file when running the tests.

like image 91
Martin Brugger Avatar answered Nov 14 '22 21:11

Martin Brugger