Cucumber/Maven: How to make variable in pom.xml fo

2019-09-18 03:24发布

问题:

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.

Type in cmd:

mvn verify -Dfeature=Forum.feature -DdryRun=false

but I got error. -DdryRun options does not works.

Please take a look screenshot http://imgur.com/6p11Y6V

回答1:

According to your screenshot you have the following configuration:

<systemPropertyVariables>
    <cucumber.options>
        <![CDATA[--tags ${tags} ${dryRun} [${cucumber.features.dir}/${feature}]]>
    </cucumber.options>
</systemPropertyVariables>

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.

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.