我一直试图进行简单的黄瓜测试。 但它给了我以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: cucumber/io/ResourceLoader
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at cucumber.runtime.Reflections.hasConstructor(Reflections.java:51)
at cucumber.runtime.Reflections.instantiateSubclasses(Reflections.java:28)
at cucumber.runtime.Runtime.loadBackends(Runtime.java:96)
at cucumber.runtime.Runtime.<init>(Runtime.java:63)
at cucumber.api.cli.Main.run(Main.java:24)
at cucumber.api.cli.Main.main(Main.java:16)
Caused by: java.lang.ClassNotFoundException: cucumber.io.ResourceLoader
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 10 more
我的测试看起来像这样。我认为缺少一个jar文件。不熟悉黄瓜设置
Feature: AddUser
In order to perform operations on the library system
I want to be able to add a valid user.
Scenario: Add unique user
Given I have entered a username Ali
And I have entered a password 22
And I have entered a given name ali
And I have entered a family name abbas
And I have entered a middle Initial F
And I have entered a email ali@gmail.com
And I have entered a roleID Member
When I press Create User
Then a new user should be added
答案 0 :(得分:3)
看起来你错过了黄瓜核心库。
尝试将以下内容添加到依赖项中。
https://mvnrepository.com/artifact/info.cukes/cucumber-core/1.2.5
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>