cucumber.runtime.CucumberException: 未找到后端

cucumber.runtime.CucumberException: No backends were found

我正在尝试 运行 在 Maven 项目中使用黄瓜进行 BDD 测试。 当我尝试 运行 BDDdemo.feature 时,出现以下错误

Exception in thread "main" 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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

环境

openjdk 版本:13.0.1
阿帕奇行家:3.6.3
TestNG:6.14.3
黄瓜:1.2.6
IDE:IntelJ IDEA

依赖关系

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.6</version>
            <!--<type>pom</type>-->
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>1.2.6</version>
            <!--<type>pom</type>-->
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.6</version>
            <!--<type>pom</type>-->
        </dependency>
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>5.3.0</version>
        </dependency>

关于这个问题,我已经尝试了堆栈溢出中的所有解决方案。但对我没有任何作用。
谁能帮我解决这个问题?

我假设,根据您的 pom.xml 片段,您正在使用 TestNGJunit。因此,您需要添加 cucumber-testng(它已经存在)和 cucumber-junit(它丢失)作为黄瓜后端。请考虑将此其他依赖项添加到 pom.xml:

上的依赖项部分
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.6</version>
    </dependency>

PS:您列出的所有依赖项似乎都是测试范围的,因此,请考虑将 <scope>tests</scope> 添加到每个依赖项中,以避免不必要地将这些库添加到您的最终包(如果您要打包 JAR)。