Search code examples
testingselenium-webdrivertestng-eclipse

Why do non-unique group names in TestNG tests affect other test classes? Can I use the same group names in different test classes?


I have the same group names for the methods in 2 of my test classes in TestNG, e.g.:

@Test(description = "step 4", groups = "4", dependsOnGroups = "3")

However, when I run one of these tests, the other one gets automatically included in the temporary xml file and it runs, as well. I want to keep my group names relatively simple and don't want them to be unique. Is this possible or I should make them unique?


Solution

  • Groups are used exactly for this purpose - to collect test methods from all packages/classes. If test method has dependsOnGroups param, all related test methods will be triggered from all classes. If you want to prioritize your tests use priority param for @Test.