How to run mvn cucumber test using jar file?

烂漫一生 提交于 2020-01-16 19:42:26

问题


I have created a test automation framework using maven and cucumber.

1) I want to create a jar file which includes everything (all project files)

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')

I don't want to use the main method or anything.


回答1:


java -Dcucumber.options="--tags @all" -jar your-test-jar.jar

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.

Update:

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.

This should help you run Cucumber from your executable.



来源:https://stackoverflow.com/questions/51437433/how-to-run-mvn-cucumber-test-using-jar-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!