我试图通过cucumber.api.cli.main.main运行cucumber,但它给出了以下错误(请注意,在ide中它可以正常工作)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:109)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: cucumber.runtime.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.
at cucumber.runtime.Runtime.<init>(Runtime.java:81)
at cucumber.runtime.Runtime.<init>(Runtime.java:70)
at cucumber.runtime.Runtime.<init>(Runtime.java:66)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main.main(Main.java:18)
at br.com.xxx.service.xxx.test.TesteCucumber.main(TesteCucumber.java:17)
... 8 more
我的主课
@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = { "br.com.xxx" })
@SpringBootApplication
public class TesteCucumber {
public static void main(String[] args) throws Throwable {
String[] arguments = {"..\\src\\test\\resources\\","-g", "br.com.xxx.service.xxx.test.cucumber.steps"};
cucumber.api.cli.Main.main(arguments);
}
}
我的pom配置
<properties><cucumber.version>1.2.5</cucumber.version></properties>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
</dependency>
spring引导jar中的所有依赖项都正常
我已经搜索了一些类似的问题,但没有找到答案
你能帮我解决这个错误吗?提前谢谢。
1条答案
按热度按时间xa9qqrwz1#
我这样解决了这个问题
在pom.xml中,我将maven配置为添加main类cucumber.api.cli.main
我在课堂上取消了考试
我运行mvn包
我将所有jar依赖项复制到文件夹/lib/
我运行下面的命令行: