Alternate way to run Cucumber without JUnit?(在没有 JUnit 的情况下运行 Cucumber 的替代方法?)
问题描述
有没有其他方法可以在没有 Junit 的情况下运行黄瓜.
Is there any alternate way to run the cucumber without Junit.
是否有任何可能的方式将 cucumber 作为 Java 应用程序运行.. 就像我创建一个 main() 方法并控制那里的所有步骤定义?
Is that any possible way to run cucumber as a Java application.. like if I create a main() method and control all step definitions over there?
任何帮助都会很棒
推荐答案
可以从命令行调用 Cucumber JVM.所以下面的答案适用于任何可以从命令行调用的 Java 代码,而不仅仅是 Cucumber JVM(它只是另一个 Java 组件/库).
Cucumber JVM can be invoked from command line. So the answer below applies to any Java codes that can be invoked from command line, not just for Cucumber JVM (which is just another Java component/library).
您可以通过静态方法调用从您自己的 main 方法(或任何其他方法)调用任何 Java main 方法.我们只需要模拟命令行参数是如何传递的.
You can invoke any Java main method from your own main method (or any other methods) through static method invocation. We just need to simulate how the command line arguments being passed.
因此,如果您能够从命令行调用 Cucumber JVM:
So if you are able invoke the Cucumber JVM from command line:
java -jar cucumber-jvm.jar cucumber.api.cli.Main --strict --glue com.mycompany.glue --plugin pretty
这是一个示例,您可以如何使用自己的 Java 代码做到这一点:
This is an example how you can do that from your own Java code:
public class MyMainClass {
public void main(String[] args) {
String[] args = new String[] {
"--strict",
"--glue",
"com.mycompany.glue",
"--plugin",
"pretty"
};
cucumber.api.cli.Main.main(args);
}
}
这篇关于在没有 JUnit 的情况下运行 Cucumber 的替代方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在没有 JUnit 的情况下运行 Cucumber 的替代方法?


- 如何指定 CORS 的响应标头? 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 转换 ldap 日期 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 获取数字的最后一位 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01