我正在尝试使用黄瓜中的示例表的场景大纲 . 但抛出异常 . cucumber.runtime.CucumberException:无法创建场景运行器我尝试使用各种版本的Junit和黄瓜 . 任何人都可以建议正确版本的junit与黄瓜一起使用,以便这样做 . 其他黄瓜选项工作正常,除此之外 . 我已经使用了junit 4.12和黄瓜1.2.5,但就场景大纲而言没有用 .
你应该看看异常的原因 . 由于code which throws the exception表明原因用于构造 CucumberException
CucumberException
} catch (InitializationError e) { throw new CucumberException("Failed to create scenario runner", e); }
例如,如果您的类 runner.Runner 不是 public class ,则生成的异常消息将如下所示
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 .
CucumberOption
cucumber.runtime.CucumberException: Unknown option: --wrong-option
我相信在异常消息中会有更多的解释 . 最好的是你为你的跑步者提供代码 .
我尝试了许多版本的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>
2 回答
你应该看看异常的原因 . 由于code which throws the exception表明原因用于构造
CucumberException
例如,如果您的类
runner.Runner
不是public class
,则生成的异常消息将如下所示编辑:此示例是使用JUnit 4.12完成的 . JUnit 4.11和4.12中的检查不同 . 所以这不会在JUnit 4.11中引发异常 .
一个JUnit 4.11案例可能是错误的
CucumberOption
.我相信在异常消息中会有更多的解释 . 最好的是你为你的跑步者提供代码 .
我尝试了许多版本的Junit和黄瓜 . 经过2-3个小时的奋斗,我终于能够创造出试验跑步者 . 使用以下依赖项 . 这种组合对我有用