gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 21:41:13 25 4
gpt4 key购买 nike

在 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(), 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)

尝试通过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”。
cucumber-java settings
然后正确加载 BindingUpdater 并且在运行测试时所有特定于geb 的方法都在步骤文件中可用。

关于groovy - 使用 groovy 在 IntelliJ IDE 中运行 Cucumber Geb 测试时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25780040/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com