线程“main”cucumber.runtime.CucumberException中的异常:未找到后端

问题描述 投票:9回答:6

我正在使用Cucumber开发我的Selenium-JVM框架,并且在运行我的第一个功能时出现以下错误。

请帮忙。

我是如何推出这项功能的 -

  1. 右键单击要素文件
  2. 选择Run As - > Cucumber 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:78)
    at cucumber.runtime.Runtime.<init>(Runtime.java:67)
    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)

我在代码中有什么 -

launcher.Java -

package cucumber;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(format={"pretty","json:target/"} , features="/src/test/java/cucumber/features")
public class Launcher {

}

功能文件 -

Feature: it works demo

  Scenario: First test
    Given this is my step
    When this is my second step
    Then this is my final step

列表中添加的依赖项列表 -

cucumber-core-1.1.8
cucumber-html-0.2.3
cucumber-java-1.1.8
cucumber-junit-1.1.8
cucumber-jvm-deps-1.0.3
gherkin-2.12.2
hamcrest-all-1.3
junit-4.11
selenium-api-2.42.2
selenium-firefox-driver-2.42.2
selenium-java-2.42.2
selenium-remote-driver-2.42.2
selenium-support-2.42.2

我的JVM - 1.7

项目中只有这么多。

请帮忙。

java selenium-webdriver cucumber-jvm
6个回答
10
投票

确保您为Maven项目添加以下依赖项:

您可以将版本替换为最新版本或所需版本:

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.0</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.0</version>
    </dependency>

13
投票

如果在类路径中找不到“后端”,则抛出此错误。每种支持的语言都有一个“后端”(例如,黄瓜-java,黄瓜-groovy等)

它可能是一个类路径错误,尽管如果黄瓜核心和黄瓜-java位于相同的位置似乎很奇怪。


0
投票

你可以在https://mvnrepository.com/artifact/info.cukes/cucumber-java/1.2.4尝试黄瓜-java-1.2.4。

我发现尝试使用相同JAR文件的先前版本对我有用。我想这也可以为其他人解决。如果没有,请添加另一个答案。

让我知道它是否适合你并节省了一些宝贵的时间:-)


0
投票

这是修复:在eclipse项目中,在.project文件中添加以下内容

<buildSpec>
  ...
  <buildCommand>
	<name>cucumber.eclipse.steps.jdt.stepsBuilder</name>
	<arguments>
	</arguments>
  </buildCommand>
</buildSpec>
<natures>
  ...
  <nature>cucumber.eclipse.steps.jdt.stepsNature</nature>
</natures>

如果这不能解决问题,请添加依赖项

黄瓜的Java

在项目类路径中或将jar的版本更改为最新版本或n-1


-1
投票

尝试在Eclipse中运行Cucumber功能文件时遇到了同样的错误消息(“没有找到后端。请确保在CLASSPATH上有后端模块”)。

为我修复它的是进入我的pom.xml并将cucumber-java和cucumber-junit版本从1.2.5(per their documentation)更改为1.2.0。

我不是百分百肯定我是否通过这样做而忽略了一个真正的问题。以下是有关我的设置的更多信息:

  • Windows 10
  • Eclipse Neon(4.6.0)
  • Apache Maven 3.5.0
  • Java 1.8

我通过快速命令验证java和maven已成功安装并在我的机器上运行。我还验证了Maven在我的Eclipse项目中引入了黄瓜-java和黄瓜核心罐。奇。


-1
投票

添加以下依赖项我解决了这个问题

   <dependency>
       <groupId>io.cucumber</groupId>
       <artifactId>cucumber-java</artifactId>
       <version>4.2.6</version>
   </dependency>
© www.soinside.com 2019 - 2024. All rights reserved.