1
votes

Here is my problem. I have a @env tag on feature level to identify which env to run on, and @current tag on scenario level to identify its the one to be run.

Feature files are placed under different folders (depending on the env) and I have used @Cucumberoptions to set the tag specific feature file path.

All good till here.

But when I run the feature files, it picks up all the scenarios with the @current tag irrespective of the feature file tag. For E.G. I had added only @Env1 and @Env2 in the cucumber options, but it picks up @Env3 features as well and runs them. How do I stop cucumber to run feature files not mentioned in the @cucumberOptions?

Here is the ANT target code:

<java classname="cucumber.api.cli.Main" fork="true" failonerror="false" resultproperty="cucumber.exitstatus"> <sysproperty key="log4j.configuration" value="file:///${basedir}/log4j.conf"/> <classpath refid="classpath"/>
<arg value="--monochrome"/> <arg value="--format"/> <arg value="junit:target/cucumber-junit-report/allcukes.xml"/> <arg value="--format"/> <arg value="pretty"/> <arg value="--format"/> <arg value="html:target/cucumber-html-report"/> <arg value="--glue"/> <arg value="src.test.cucumber.userlevel"/> <arg value="features"/> <arg value="--tags" /> <arg value="@current"/> <arg value="--tags" /> <arg value="~@obsolete" /> <arg value="--tags" /> <arg value="~@business" />
</java>

Any responses would be appreciated.

Thanks.

1

1 Answers

1
votes

Need to use a AND, OR combination in the tag filter expression to make this work. Not too sure about how to run Cucumber from Ant so including tag filters in cucumberoptions and from cli.

For cucumberoptions -> tags={"@Env1,@Env2","@Current"}

For CLI -> --tags @Env1,@Env2 --tags @Current

For Ant ->

<arg value="--tags" />
<arg value="@Env1,@Env2"/>
<arg value="--tags" />
<arg value="@Current" />