简体   繁体   English

从命令行在Maven中设置cucumber-jvm选项

[英]Setting cucumber-jvm options in Maven from the command line

I am trying to set the "name" option for Cucumber to be able to run a specific feature or scenario. 我正在尝试为Cucumber设置“名称”选项,以便能够运行特定功能或方案。

I have entered this, 我进入了这个,

mvn test -DCucumber.Options--name="MyFeatureName"

but it just runs all the features and doesn't give an error. 但它只是运行所有功能,并没有给出错误。

Any ideas? 有任何想法吗?

Here is a snippet from the Cucumber-JVM repo on how to run the java-helloworld example by passing cucumber options: 以下是Cucumber-JVM repo中关于如何通过传递黄瓜选项来运行java-helloworld示例的片段

mvn test -Dcucumber.options="--format json-pretty --glue classpath:cucumber/examples/java/helloworld src/test/resources"

Keep in mind that it will override all the options in the @Cucumber.Options annotation you have on "RunCukesTest". 请记住,它将覆盖您在“RunCukesTest”上的@ Cucumber.Options注释中的所有选项。 I haven't got it to work for my own tests but maybe this will help. 我没有让它为我自己的测试工作,但也许这会有所帮助。

So it looks like you need to give all the options needed to run cucumber, including the java class path and where the code is located using the "--glue" parameter. 所以看起来你需要提供运行黄瓜所需的所有选项,包括java类路径和代码所在的位置使用“--glue”参数。

您的测试在单独的JVM中运行,因此您需要在测试插件配置中指定该系统属性(即pom.xml中的surefire或failsafe插件配置)。

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

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