黄瓜场景大纲不适用于Junit 4.11和Cucumber 1.2.5

问题描述 投票:0回答:2

我正在尝试使用黄瓜中的示例表的场景大纲。但抛出异常。 cucumber.runtime.CucumberException:无法创建场景运行器我尝试使用各种版本的Junit和黄瓜。任何人都可以建议正确版本的junit与黄瓜一起使用,以便这样做。其他黄瓜选项工作正常,除此之外。我已经使用了junit 4.12和黄瓜1.2.5,但就场景大纲而言没有用。

java cucumber junit4 cucumber-java cucumber-junit
2个回答
0
投票

你应该看看异常的原因。正如code which throws the exception所说,原因被用来构建CucumberException

} catch (InitializationError e) {
    throw new CucumberException("Failed to create scenario runner", e);
}

例如,如果您的类runner.Runner不是public class,则生成的异常消息看起来像

java.lang.Exception: The class runner.Runner is not public.

编辑:此示例是使用JUnit 4.12完成的。 JUnit 4.11和4.12中的检查不同。所以这不会在JUnit 4.11中引发异常。

一个JUnit 4.11案例可能是一个错误的CucumberOption

cucumber.runtime.CucumberException: Unknown option: --wrong-option

我相信在异常消息中会有更多的解释。最好的是你为你的跑步者提供代码。


0
投票

我尝试了许多版本的Junit和黄瓜。经过2-3个小时的奋斗,我终于能够创造出试验跑步者。使用以下依赖项。这种组合对我有用

<dependencies>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.4.0</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.0.14</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.0.14</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>1.0.14</version>
</dependency>

© www.soinside.com 2019 - 2024. All rights reserved.