[英]Running cucumber test file from application button
I've set up a test file in src/main/java with my cucumber annotations containing class A, as well as a test file extending class A in src/test/java with the following annotation on class B: 我已经在src / main / java中设置了一个包含A类的黄瓜注释的测试文件,并在src / test / java中使用了对B类以下注释的扩展了A类的测试文件:
@ContextConfiguration(locations = {"classpath:META-INF/application-config.xml", "classpath:META-INF/overrule.xml" })
This is working fine when I do a maven clean install. 当我进行Maven全新安装时,这工作正常。 What I would like to achieve though is being able to run a feature file through the cucumber setup of class A and see its output. 我想要实现的是能够通过A类的黄瓜设置运行功能文件并查看其输出。 So far I've managed to find a method which should allow me to run the cucumber test, but I can't seem to figure out what its arguments should be. 到目前为止,我已经设法找到了一种方法,可以让我运行黄瓜测试,但是我似乎无法弄清楚其参数应该是什么。 Could anyone provide me with an example of how to implement the function cucumber.api.cli.Main.run()? 谁能为我提供一个如何实现功能cumulment.api.cli.Main.run()的示例?
@Override
public void buttonClick(final ClickEvent event) {
try {
final String[] arguments = {"foo", "bar" };
cucumber.api.cli.Main.run(arguments, ClassLoader.getSystemClassLoader());
} catch (final Throwable e) {
e.printStackTrace();
}
}
I would invoke the command line version using cucumber.api.cli.Main.main(args);
我将使用cucumber.api.cli.Main.main(args);
调用命令行版本cucumber.api.cli.Main.main(args);
where args
is a String array with the parameters set. 其中args
是设置了参数的String数组。 I would not use the run command you refer to. 我不会使用您引用的run命令。
The documentation describes all available options. 该文档描述了所有可用的选项。
Another source may be the getting started project supplied by the Cucumber team: https://github.com/cucumber/cucumber-java-skeleton 另一个来源可能是Cucumber团队提供的入门项目: https : //github.com/cucumber/cucumber-java-skeleton
It may be of specific interest to look into the Ant build script https://github.com/cucumber/cucumber-java-skeleton/blob/master/build.xml to see what arguments they supply to Cucumber. 查看Ant构建脚本https://github.com/cucumber/cucumber-java-skeleton/blob/master/build.xml可能特别感兴趣,以查看它们提供给Cucumber的参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.