简体   繁体   中英

Run cucumber test execute from jar with command line --tags @my-tag

I have built a cucumber test executable jar using the maven-assembly-plugin option and was successfully run the executable jar that run all the cucumber test within it.

However, I like to try to run the executable with optional tags specified on the command line but could not seem to do so. Any help and suggestion would be greatly appreciate.

My sample code is in github:

https://github.com/txt8888/cucumber-executable

You could use the main() method of the Main class from the io.cucumber.core.cli.Main package.

public class DreamCarMain {
    public static void main(String[] args) {

        Main.main(new String[] { "-g", "org.phan.kata.cucumber.integration.stepdefs", "-p", "pretty", "-t", args[0], "classpath:features" });
    }
}

There is no need for the RunWith and CucumberOptions annotation. Replace the TagExpression with whatever tags u want to execute. If you want to do some action after the call then use the run() method instead of the main() .

java -jar cucumber-integration-1.0.0-jar-with-dependencies.jar @TagExpression

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM