0

I have got such 3 groups (3 tests) in my testng project code, for example:

groups = {"iOS", "Android", "Sync"})

groups = {"iOS", "Sync"})

groups = {"Android", "Sync"})

How can I run all tests which contain some groups, for example: "Android" AND "Sync"?

If I run:

mvn clean test -PAndroid -Dgroups=Android,Sync

I will run all 3 tests because this syntax works: "Android" OR "Sync", but I need only the first and the third test to be run.

  • You will have to use annotation transformer for conditional enable disable of test https://stackoverflow.com/questions/3945769/how-to-disable-testng-test-based-on-a-condition – Rahul L Dec 20 '19 at 11:43

3 Answers3

1

Why dont you try a tag expression Android&Sync

https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions

This might require some single or double quotes on your command line

(perhaps "-Dgroups=Android&Sync" - though I havent tried it.)

vikingsteve
  • 38,481
  • 23
  • 112
  • 156
0

You can try using by creating the profiles of your groups in maven.

or

You it like this- Dgroups='Andriod', -Dgroups='sync'

Sobhit Sharma
  • 697
  • 14
  • 45
0

Another way is, exclude IOS group, use this (note excluded vs exclude). here is docs

mvn test -DexcludedGroups==IOS
Muzzamil
  • 2,823
  • 2
  • 11
  • 23