我有一个项目在groovy中(不是Maven结构)如何,当我查看功能时
Feature: API Authentication Functionality @Api @General Scenario: I cannot log in to the API with bad credentials Given the following users are defined: | USER_EMAIL | RAW_PASSWORD | | test@test.reachforce.com | YesGoodPassword! | And I use the username 'test@test.reachforce.com' And I use the password 'UhOhWrongWord!' When I log in to the API Then the response is forbidden @Api @General Scenario: I log in to the API Given the following users are defined: | USER_EMAIL | RAW_PASSWORD | | test@test.reachforce.com | YesGoodPassword! | And I use the username 'test@test.reachforce.com' And I use the password 'YesGoodPassword!' When I log in to the API Then the response is valid And the response includes a token
但是在步骤中会出现此警告:
step the following users are defined does not have a matching glue code
步骤结构类似于:AuthenticationSteps.groovy
而当我运行它给我这个错误:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:65)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:65)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:162)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at com.reachforce.tools.db.DataSourceFactory.<init>(DataSourceFactory.groovy:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:239)
at com.reachforce.config.ValidationConfig.<init>(ValidationConfig.groovy:31)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:436)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at groovy.lang.GroovyShell.parse(GroovyShell.java:680)
at cucumber.runtime.groovy.GroovyBackend.parse(GroovyBackend.java:115)
at cucumber.runtime.groovy.GroovyBackend.loadGlue(GroovyBackend.java:76)
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)
Caused by: java.io.FileNotFoundException: \etc\validation\validation.properties (El sistema no puede encontrar la ruta especificada)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite.callConstructor(ConstructorSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
at com.reachforce.config.ValidationEnvironment.<clinit>(ValidationEnvironment.groovy:10)
... 36 more
有什么帮助吗?
最佳答案
看起来您的Cucumber插件找不到步骤定义类。
尝试看一下使用Groovy步骤定义运行Cucumber的示例:
Cucumber-jvm-groovy-example
关于maven - 我如何在Groovy项目中使用 cucumber 定义缺少的步骤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40407816/