java 从命令行在 Maven 中设置黄瓜 jvm 选项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12711189/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 09:55:59  来源:igfitidea点击:

Setting cucumber-jvm options in Maven from the command line

javamavencucumber-jvm

提问by The Cat

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?

有任何想法吗?

回答by Fab

Here is a snippetfrom the Cucumber-JVM repo on how to run the java-helloworld example by passing cucumber options:

这是Cucumber-JVM 存储库中关于如何通过传递黄瓜选项来运行 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". I haven't got it to work for my own tests but maybe this will help.

请记住,它会覆盖您在“RunCukesTest”上的 @Cucumber.Options 注释中的所有选项。我还没有让它用于我自己的测试,但也许这会有所帮助。

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”参数的代码所在位置。

回答by Eugene Kuleshov

Your tests are running in separate JVM, so you need to specify that system property in the test plugin configuration (i.e. surefire or failsafe plugin config in your pom.xml).

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