testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.98k stars 1.02k forks source link

[Feature Request] allow multiple groups with AND condition #3125

Open SiKing opened 4 months ago

SiKing commented 4 months ago

Currently when running tests with multiple groups, we can use syntax something like mvn test -Dgroups="groupA,groupB". This will run any tests that are tagged with "groupA" OR "groupB".

Please create an option to combine multiple groups with the AND condition. So if I specify something like mvn test -Dgroups="group1+group2", this will run any tests that are tagged with "group1" AND "group2".

There is additional discussion in the testng-users forum, here.

itkhanz commented 4 months ago

I think this is already possible, I am aware of includeGroups and excludeGroups from testng xml file: https://testng.org/#_exclusion_groups

You can also take a look at beanshell expressions to define advanced AND OR conditions to include and exclude groups based on your conditions if you have a TESTNG XML file https://testng.org/#_beanshell_and_advanced_group_selection

SiKing commented 4 months ago

Additional information: For my use case, my entire test suite has something like two-dozen different groups. At run time (in CI) I have no way of knowing what are all the groups that have been created. Adding all these as "exclude groups" is not feasible.