我如何用黄瓜从Groovy项目中定义一个缺失的步骤?

时间:2016-11-03 17:30:14

标签: maven grails groovy cucumber cucumber-jvm

我有一个项目是如何在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

但是在这些警告的步骤中出现了:

  

步骤以下用户定义没有匹配的胶水   代码

步骤结构如: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

任何帮助?

1 个答案:

答案 0 :(得分:0)

看起来你的黄瓜插件找不到步骤定义类。

  • 在构建文件中,如果您的文件夹结构不是插件所期望的,那么您需要将Cucumber指向功能和步骤定义的位置。

尝试查看此示例以使用Groovy步骤定义运行Cucumber: Cucumber-jvm-groovy-example