'Multiple tags in Karate using and condition

I have the below variety of tags in my scenarios. These scenarios are distributed in multiple feature files.

  1. @smoke
  2. @smoke @prod
  3. @Regression
  4. @Regression @prod

I am executing karate jars via command line as below:

java -cp some-jar-with-dependecies:. -Dkarate.config.dir=. -jar  some-jar-with-dependecies.jar *.feature -T 1 -t "@smoke","@prod" -e prod

I was expecting scenarios with only @smoke @prod i.e only #2 to get executed.

But I am getting reports with #1,#2,#4 variations. It seems the tags mentioned in the command line are working as OR condition (@smoke or @ prod).

I am trying to call the scenarios with an AND condition in the tag.

Please help me on how to execute the scenarios with a tag AND condition (@smoke AND @prod).

I found some similar questions in Stack Overflow. But those solutions are not working for me: Using multiple tags to run in karate options



Solution 1:[1]

Did you try:

-t @smoke -t @prod

Which should be "smoke and prod"

Also:

-t @smoke -t @prod,@reg

Should be "smoke AND (prod OR reg)"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Thomas