问题
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