Reputation: 57
We can select multiple scenario's by including the following on the command line: -Dcucumber.options="--tags @S1,@S2,@S6"
And if I want to exclude @S6 I can with: -Dcucumber.options="--tags ~@S6"
But if I want to include @S1, @S2 and exclude @S6 all tags are ignored with: -Dcucumber.options="--tags @S1,@S2,~@S6"
and all tags are also ignored if I try to double up on the options with: -Dcucumber.options="--tags @S1,@S2" -Dcucumber.options="--tags ~@S6"
Is there a command line way to include and exclude in the one command line?
The reason I would like to do this is to run all of a type of test but exclude tests that use some external system that may be down temporarily.
Upvotes: 2
Views: 8673
Reputation: 58098
EDIT: Turns out I was not fully aware of the difference between AND and OR in the Cucumber world. This SO answer and this article was a good reference, look for "Logical OR" and "Logical AND":
so to run S1 OR
S2 AND NOT
S3
mvn test -Dkarate.options="--tags @S1,@S2 --tags ~@S3"
Using the Java (or Runner
) API, just use commas for OR and separate strings for AND:
Results results = Runner.path("classpath:com/myco/some.feature")
.tags("@S1,@S2", "~@S3")
.parallel(5);
For really advanced cases, also see: https://stackoverflow.com/a/67224240/143475
Upvotes: 7