Groovy   发布时间:2022-04-12  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使用groovy在IntelliJ IDE中运行Cucumber Geb测试时出错大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在IntelliJ IDE中运行Geb测试时遇到以下错误.

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(),any(),any(groovy.lang.ClosurE),with(groovy.lang.ClosurE)
  at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:97)
  at groovy.lang.@L_388_2@method.doMethodInvoke(@L_388_2@method.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),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)

尝试通过Geb访问网页时,步骤定义文件中出错

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

    to MyLandingPage
    waitFor { at(MyLandingPagE) }
}

使用gradle test命令在命令行中完美地运行测试

解决方法

我有同样的问题,终于找到了解决方案.根据示例项目 https://github.com/geb/geb-example-cucumber-jvm.git,您需要确保在运行配置的胶水列表中也引用了文件’env.groovy’.

使用groovy在IntelliJ IDE中运行Cucumber Geb测试时出错

然后正确加载Bindingupdater,并在运行测试时在步骤文件中提供所有geb特定方法.

大佬总结

以上是大佬教程为你收集整理的使用groovy在IntelliJ IDE中运行Cucumber Geb测试时出错全部内容,希望文章能够帮你解决使用groovy在IntelliJ IDE中运行Cucumber Geb测试时出错所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。