如何使用 jar 文件运行 mvn 黄瓜测试?
我已经使用 maven 和 cucumber 创建了一个测试自动化框架.
I have created a test automation framework using maven and cucumber.
1) 我想创建一个包含所有内容(所有项目文件)的 jar 文件
1) I want to create a jar file which includes everything (all project files)
2) 然后我想使用上面创建的 jar 从命令行运行测试,就像使用命令一样
2) Then I want to run a test from the command line using above created jar like using the command
(mvn clean test -Dcucumber.options='--tags @all'
)
我不想使用 main 方法或任何东西.
I don't want to use the main method or anything.
推荐答案
java -Dcucumber.options="--tags @all" -jar your-test-jar.jar
试试这个.虽然我不确定你为什么不想使用 main 方法.如果不使用 main 方法,那就太复杂了.
Try this. Although I am not sure why you don't want to use the main method. If you don't use the main method it will just become too complicated.
更新:
编写一个 main 方法并从中运行 Cucumber main 方法.这些参数是您将作为 Cucumber 命令行参数传入的内容.
Write a main method and run Cucumber main method from it. The arguments are what you would pass in as your Cucumber command line arguments.
public static void main(String[] args) throws Throwable {
String[] arguments = {"a", "b"};
cucumber.api.cli.Main.main(arguments);
}
如果我清楚地理解了您的问题,这可能会完成您的工作.
If I have understood your question clearly, this might do your work.
这应该可以帮助您从可执行文件中运行 Cucumber.
This should help you run Cucumber from your executable.
相关文章