使用 Cucumber v1.2.4 时运行 Cucumber 测试的方法没有签名

我在设置自己的开发环境时遇到问题。我正在使用 eclipse phontom 和eclipse-groovy,Cucumber Eclipse plugin并想加入使用 groovy 和 cucumber 编写测试代码的开发。


起初我io.cucumber.cucumber-groovy:4.5.3通过 maven 导入 cucumber ( ) 的依赖项,一切正常。然而,几天后,同事告诉我,他们过去常常使用旧版本(info.cukes.cucumber-groovy:1.2.4)导入依赖项。降级后我的笔记本电脑里的一切都坏了。


例如,以下是 的简单步骤定义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()

}

当我在笔记本电脑上运行它时,会引发以下异常。


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)

我应该做些什么来使事情在依赖性下工作info.cukes.cucumber-groovy:1.2.4?


以下是我的可能相关的开发环境:


JDK: Amazon Corretto-8.212.04.2 (build 1.8.0_212-b04)

Maven: 3.3.9

Groovy compiler in eclipse: 2.4.17

任何建议,将不胜感激。谢谢!


墨色风雨
浏览 150回答 1
1回答

杨__羊羊

好的,我想我已经找到原因了。可能是cucumber 1.2.4不支持如下格式的步骤定义导致的:Given(/an&nbsp;item&nbsp;ID&nbsp;which&nbsp;does&nbsp;not&nbsp;exist/)&nbsp;{&nbsp;-> &nbsp;&nbsp;&nbsp;&nbsp;.... }当我将样式更改为正则表达式格式时,它再次起作用。Given(~/^an&nbsp;item&nbsp;ID&nbsp;which&nbsp;does&nbsp;not&nbsp;exist$/)&nbsp;{&nbsp;-> &nbsp;&nbsp;&nbsp;&nbsp;.... }感谢 Mark Rotteveel 的建议!
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java