java - 在 cucumber junit中发现没有后端

标签 java selenium maven junit cucumber

我正在尝试使用 junit 运行 cucumber testRunner,但出现“未找到后端”异常。我找到了类似的异常解决方案,但它们遇到了运行时异常,而我的与该异常不同。有人可以研究一下吗?

测试运行器

package testRun;


import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import io.cucumber.testng.AbstractTestNGCucumberTests;

@RunWith(Cucumber.class)
@CucumberOptions(features="/OpenCart/src/test/resources/testFeature",glue= {"stepDefinitions"},
plugin = { "pretty", "html:target/cucumber-reports" })

public class TestRunner extends AbstractTestNGCucumberTests{

}

异常

io.cucumber.core.exception.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.
    at io.cucumber.core.runtime.BackendServiceLoader.get(BackendServiceLoader.java:36)
    at io.cucumber.core.runtime.BackendServiceLoader.get(BackendServiceLoader.java:30)
    at io.cucumber.core.runtime.ThreadLocalRunnerSupplier.createRunner(ThreadLocalRunnerSupplier.java:50)
    at java.lang.ThreadLocal$SuppliedThreadLocal.initialValue(ThreadLocal.java:284)
    at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:180)
    at java.lang.ThreadLocal.get(ThreadLocal.java:170)
    at io.cucumber.core.runtime.ThreadLocalRunnerSupplier.get(ThreadLocalRunnerSupplier.java:44)
    at io.cucumber.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:146)
    at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:83)
    at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at io.cucumber.junit.Cucumber.runChild(Cucumber.java:185)
    at io.cucumber.junit.Cucumber.runChild(Cucumber.java:83)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at io.cucumber.junit.Cucumber$RunCucumber.evaluate(Cucumber.java:219)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

我的 pom 文件中有所有依赖项,请查找以下依赖项详细信息

依赖项详细信息

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>5.7.0</version>
    <scope>test</scope>
</dependency>
  
  <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>5.7.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>4.1.2</version>
</dependency>


<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-core</artifactId>
    <version>5.7.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>gherkin</artifactId>
    <version>13.0.0</version>
</dependency>

 <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
<!--<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>6.0.0-RC2</version>
</dependency> -->

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-gherkin -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-gherkin</artifactId>
    <version>5.7.0</version>
</dependency>


<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-jvm-deps -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-jvm-deps</artifactId>
    <version>1.0.6</version>
    <scope>provided</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.13.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>4.1.5</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.2</version>
</dependency>


<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
</dependency>


<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.7.1</version>
</dependency>


<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-all</artifactId>
    <version>1.10.19</version>
    <scope>test</scope>
</dependency>

文件结构

enter image description here

最佳答案

将 cucumber jar 更新到最新版本解决了我的问题

关于java - 在 cucumber junit中发现没有后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62189075/

相关文章:

java - 在我的应用程序中检查 WRITE_SECURE_SETTINGS 权限时出现问题

java - 如何在 JAR 中包含 ChromeDriver?

java - Maven、spring、tomcat7 : What do I need in pom. xml 部署正确?

java - 需要java API来解析SQL语句

java - 这是有效的日期格式吗 - 2007-12-13+01 :00?

python - selenium.common.exceptions.InvalidSessionIdException 通过 Python 在 headless 模式下使用 GeckoDriver Selenium Firefox

maven - 为什么使用 Maven 版本插件(版本 :use-latest-versions) not updating/changing -SNAPSHOT version to release (none -SNAPSHOT version)?

maven - 依赖 javax.mail :mail:1. 4 未找到

java - 如何从我的代码中的 JMeter 测试计划中读取变量?

python - "http.client.CannotSendRequest: Request-sent"错误