当前位置: 首页 > 知识库问答 >
问题:

在cucumber junit中找不到后端

姜景辉
2023-03-14

我试图用junit运行cucumber testRunner,但我得到了“没有发现后端”异常。我发现了类似的exeception解决方案,但它们会得到运行时异常,而我的解决方案与该异常不同。有人能调查一下吗。

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>

共有1个答案

国晟睿
2023-03-14

更新黄瓜罐子最新解决了我的问题

 类似资料:
  • 这是一个类似的问题,但提出的解决方案不起作用:安装后没有找到命令'gulp'

  • 问题内容: 我有一个问题:nodemon不能运行npm脚本(例如), 但是如果在npm脚本之外的命令行上调用nodemon ,则nodemon会正常运行。 在npm脚本中如何调用它: 运行npm start脚本时: 我一直在寻找解决方案,但没有找到解决方案。 问题答案: 您可以通过添加以下内容来解决此问题: 在中不存在时会发生问题。 已添加,因为仅在开发期间才需要。

  • 我写了phpUnit测试。我使用以下命令运行它:

  • 问题内容: 我想使用 注释消除。我在网上找到了一些教程,我注意到这个注释来自软件包;但是当我导入它时,会生成一个编译错误:找不到符号 问题答案: 您需要包括一个存在该类的罐子。您可以在这里找到它 如果使用Maven,则可以添加以下依赖项声明: 对于Gradle:

  • System:OS:Linux 5.3 Ubuntu 18.04.4 LTS(仿生海狸)CPU:(4)x64 Intel(R)Core(TM)i5-4300U CPU@1.90GHz内存:378.16MB/7.66GB shell:4.4.20-/bin/bash二进制文件:node:12.16.1-/usr/bin/node yarn:1.21.1-/usr/bin/yarn npm:6.13.

  • Netbeans是使用ubuntu软件管理器安装的。 netbeans网站上关于在netbeans中设置maven项目的说明如下: 选择文件 但是maven类别不在我的安装中。 也在网站上: 在选项窗口中选择杂项类别,然后单击Maven选项卡 但根本没有maven标签。maven不在那里的原因是什么?我怎样才能让它工作? 谢谢