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.
So you're using a rather old version of Cucumber. And a lot of things about it are rather weird. For example
cucumber.optionsaccepts command line arguments.This means that:
is interpreted as the command line option:
Which is then read as:
So you have to tell Cucumber that the tag expression belongs together:
Which you then nest into another command line argument:
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 @tag2which does behave normally. You can find the release notes to help you upgrade here: https://github.com/cucumber/cucumber-jvm/tree/main/release-notes