简体   繁体   English

使用命令行 --tags @my-tag 从 jar 运行 cucumber 测试执行

[英]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. 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:我的示例代码在 github 中:

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

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

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.不需要RunWithCucumberOptions注释。 Replace the TagExpression with whatever tags u want to execute.将 TagExpression 替换为您想要执行的任何标签。 If you want to do some action after the call then use the run() method instead of the main() .如果您想在调用后执行一些操作,请使用run()方法而不是main()

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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