Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dcucumber.options, how to have multiple tags

I am trying run cucumber tests using maven with following command

mvn test -Dcucumber.options="--tag @debug1"

This command works fine, however if i try something like following, i get error

mvn test -Dcucumber.options="--tag @debug1 @debug2"

Is there a way to pass in multiple tag names with cucumber run-time options?

like image 864
Rahul Lodha Avatar asked Dec 30 '15 23:12

Rahul Lodha


People also ask

How do you provide multiple tags?

Adding multiple tag parameters can be achieved by separating each tag (sometimes with numeric value) with a comma, to the end of the URL.

How do you use multiple tags in Cucumber options?

We can define each scenario with a useful tag. Later, in the runner file, we can decide which specific tag (and so as the scenario(s)) we want Cucumber to execute. Tag starts with “@”. After “@” you can have any relevant text to define your tag like @SmokeTests just above the scenarios you like to mark.

How would you run a scenario with multiple tags?

When we define multiple tags in runner class in below form ,it will be defined with the use of logical operator: 1. tags = {“@tag”, “@tag1”} : means AND condition. –It says that scenarios matching both these tag needs to be executed.


2 Answers

  • To run scenarios with @debug1 and @debug2:

Old version of Cucumber-jvm:

mvn test -Dcucumber.options="--tags @debug1 --tags @debug2" 

Actual version of Cucumber-jvm:

mvn test -Dcucumber.options="--tags '@debug1 and @debug2'" 
  • To run scenarios with @debug1 or @debug2:

Old version of Cucumber-jvm:

mvn test -Dcucumber.options="--tags @debug1,@debug2" 

Actual version of Cucumber-jvm:

mvn test -Dcucumber.options="--tags '@debug1 or @debug2'" 
like image 182
Sébastien Le Callonnec Avatar answered Sep 25 '22 15:09

Sébastien Le Callonnec


In Cucumber 6, property name has changed. Use:

mvn verify -Dcucumber.filter.tags="@debug1 or @debug2"
like image 45
awgtek Avatar answered Sep 25 '22 15:09

awgtek