Cucumber / Maven:如何使变量在pom.xml中使用Cucumber选项? [英] Cucumber/Maven: How to make variable in pom.xml for use Cucumber options?
问题描述
我需要得到功能场景,而不使用maven通过cmd运行测试。黄瓜具有 dryRun 选项。但不知道如何添加此选项到 pom.xml 。
I need get feature scenarios without running tests with maven via cmd. Cucumber has 'dryRun' option. But don`t know how to add this option to pom.xml. I tried many variants, but it not helped.
输入cmd:
mvn verify -Dfeature=Forum.feature -DdryRun=false
但我遇到了错误。 -DdryRun选项不起作用。
but I got error. -DdryRun options does not works.
请查看屏幕截图 http: //imgur.com/6p11Y6V
推荐答案
根据您的屏幕截图,您有以下配置:
According to your screenshot you have the following configuration:
<systemPropertyVariables>
<cucumber.options>
<![CDATA[--tags ${tags} ${dryRun} [${cucumber.features.dir}/${feature}]]>
</cucumber.options>
</systemPropertyVariables>
这将插入 true
或 false
到环境变量中,这不是一个有效的选项,而是解释为一个特征文件的路径。
This would insert true
or false
into the environment variable, which is not a valid option and instead gets interpreted as a path to a feature file.
而是期望参数像 - dry-run
或 - 无干运行
( https:// github。 com / cucumber / cucumber-jvm / blob / v1.2.0 / core / src / main / java / cucumber / runtime / RuntimeOptions.java#L116 )。解决方案将是这样定义你的属性:
Cucumber instead expects a parameter like --dry-run
or --no-dry-run
(https://github.com/cucumber/cucumber-jvm/blob/v1.2.0/core/src/main/java/cucumber/runtime/RuntimeOptions.java#L116). The solution would be to define your property like this:
<properties>
<dryRun>--dry-run</dryRun>
</properties>
与此无关,在特征路径前面的大括号也会导致黄瓜不能找到特征。
Unrelated to that, the opening brace before the feature path would also cause cucumber not to find the feature.
这篇关于Cucumber / Maven:如何使变量在pom.xml中使用Cucumber选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!