Cucumber : Maven : Dcucumber.options : How to have multiple tags with one of them being IGNORE TAG like "NOT @tag"

676 Views Asked by At

I am trying to run Cucumber Scenarios with Maven using below command:

mvn clean install -Pgeneric-runner -Dmaven.test.failure.ignore '-Dcucumber.options=--tags @tag1 and not @tag2'

The above Maven command is failing. However, when I am removing the "not @tag2" piece from the command, it is executing fine without any failures.

. Is it possible to fix the above maven command, so that it can execute the scenarios having "@tag1" and exclude any scenario having "@tag2".

Requesting assistance. Thank you in advance.

1

There are 1 best solutions below

0
M.P. Korstanje On

So you're using a rather old version of Cucumber. And a lot of things about it are rather weird. For example cucumber.options accepts command line arguments.

This means that:

'-Dcucumber.options=--tags @tag1 and not @tag2'

is interpreted as the command line option:

--tags @tag1 and not @tag2

Which is then read as:

--tags <the tag you want to run> <feature file> <feature file> <feature file>

So you have to tell Cucumber that the tag expression belongs together:

--tags "@tag1 and not @tag2"

Which you then nest into another command line argument:

'-Dcucumber.options=--tags "@tag1 and not @tag2"'

And that might just work. It depends a little bit on how your shell handles the quotes.

You should probably upgrade. Then you can use -Dcucumber.filter.tags=tag1 and not @tag2 which does behave normally. You can find the release notes to help you upgrade here: https://github.com/cucumber/cucumber-jvm/tree/main/release-notes