I have several testng test groups, e.g. group1,group2,group3... These are defined in my pom.xml and all get run when I execute "mvn test". What do I need to run to only execute one group without having to modify the groups configured in the pom.xml.
i.e mvn test group2 mvn test group1 mvn test group3
Groups in TestNG are specified in testng. xml under the <suite> or <test> tag. Groups under the <suite> tag apply to all the tests included under the <test> tag in that particular <suite>. To group tests in the source code, you have to use the @groups attribute of the @Test annotation.
The Maven surefire plugin provides a test parameter that we can use to specify test classes or methods we want to execute. If we want to execute a single test class, we can execute the command mvn test -Dtest=”TestClassName”.
Groups in GroupsStep 1: Open the Eclipse. Step 2: We create a java project named as "Groups_in_Groups". Step 3: Now we create a testng. xml file where we configure the above class.
Try
mvn test -Dgroups=group3,group2
I came across this question while looking how to disable particular test group and Radadiya's answer confused me a bit.
To run particular groups use this, as mentioned by Eugene Kuleshov. docs
mvn test -Dgroups=group1,group2
But to exclude some group, use this (note excluded vs exclude). docs .
mvn test -DexcludedGroups=group3,group4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With