Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run a specific testng test group via maven?

Tags:

maven

testng

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

like image 987
Tom Eustace Avatar asked May 27 '10 15:05

Tom Eustace


People also ask

How do I run a specific group in TestNG?

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.

How do I run a specific test case in Maven?

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”.

How do I run an xml group in TestNG?

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.


2 Answers

Try

mvn test -Dgroups=group3,group2 
like image 99
Eugene Kuleshov Avatar answered Oct 06 '22 01:10

Eugene Kuleshov


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 
like image 45
Mikalai Parafeniuk Avatar answered Oct 06 '22 01:10

Mikalai Parafeniuk