0

I am trying to run a multiple test on a single maven command.

testing.xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="Suite1" verbose="1"> <test name="group1" parallel="false" preserve-order="true"> <classes> <class name="apps.Test1" /> <class name="apps.Test2" /> <class name="apps.Test3" /> </classes> </test> <test name="group2" parallel="false" preserve-order="true"> <classes> <class name="apps.Test4" /> <class name="apps.Test5" /> <class name="apps.Test6" /> </classes> </test> </suite> 
  1. Run all test cases from testing.xml

    mvn -Dtests=testing.xml test

If i want to run test cases from group1 such as Test1, Test2, Test3. How can I do so ?

2 Answers 2

2

You would need to edit your surefire config to support this as below :

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>yourversion</version> <configuration> <skipTests>false</skipTests> <suiteXmlFiles> <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> </suiteXmlFiles> <properties> <property> <name>testnames</name> <value>${testNames}</value> </property> </properties> </configuration> </plugin> 

then run as : mvn test -DsuiteXmlFile=src/test/resources/xmlfilename -DtestNames=group1

Configure based on your project structure for the suitefile..

Sign up to request clarification or add additional context in comments.

Comments

0

Kindly try below command :

To Run Group : mvn test -Dtests=group1,group2

To Run Class : mvn test -Dtest=classname

5 Comments

If I try mvn test -Dtests=group1 test. All tests are running. FYI I haven't defined any group name in test file. I have mentioned only in testing.xml
No. All tests defined in testing.xml are ran.
Can you show me code where you have assigned group to classes?
I made assignment in testing.xml only not anywhere.
Seems you are doing something wrong. Did you created Maven POM xml?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.