Maven run consecutive 2 or more TestNG test suites (by using command line)

1,455 views
Skip to first unread message

Nguyen Thai Hoang

unread,
Feb 4, 2016, 3:52:57 AM2/4/16
to testng-users
Hi all,

I'm facing problem about run multiple TestNG test suites by using Maven.
I have 2 TestNG testsuites, I want to run 2nd testsuite after finish running 1st testsuite.
I tried to add commands to file .bat but it just run the first testsuite.
My current comment: mvn clean test -DsuiteXmlFile="pathtoTestNGtestsuite.xml"

My pom.xml
  <modelVersion>4.0.0</modelVersion>
  <groupId>AngularProject</groupId>
  <artifactId>AngularProject</artifactId>
  <version>1.0</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
<plugins>
      <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
</plugin>
<plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18.1</version>
        <configuration>
          <forkCount>0</forkCount>
          <suiteXmlFiles>
            <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>      
</plugins>

  </build>
  <dependencies>
  <dependency>
 <groupId>org.testng</groupId>
 <artifactId>testng</artifactId>
 <version>6.9.10</version>
</dependency>
  <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.50.1</version>
    </dependency>
  </dependencies>
  <repositories>
  <repository>
    <id>central</id>
    <name>bintray</name>
  </repository>
</repositories>
  <properties>
<jre.level>1.8</jre.level>
<jdk.level>1.8</jdk.level>
  </properties>
</project>

My fist TestNG testsuite (in my senario, I separed one test case into one class)
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Test" verbose="10">
    <test name="Suite">
        <groups>
            <dependencies />
        </groups>
        <classes>
            <class name="TestLab.Test.Test.Smoke10" />
        </classes>
    </test>
</suite>

My second TestNG testsuite

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Test" verbose="10">
    <test name="Suite">
        <groups>
            <dependencies />
        </groups>
        <classes>
            <class name="TestLab.Test.Test.Smoke11" />
        </classes>
    </test>
</suite>

Many thanks,

Krishnan Mahadevan

unread,
Feb 10, 2016, 10:06:44 PM2/10/16
to testng...@googlegroups.com
Nguyen,

Assuming that your surefire plugin entry looks like below in your pom file,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
</configuration>
</plugin>
you can run multiple suites from the command prompt using Maven surefire plugin by using the command

mvn clean test -Dsurefire.suiteXmlFiles=src/test/resources/suite1.xml,src/test/resources/suite2.xml


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Nguyen Thai Hoang

unread,
Feb 12, 2016, 8:00:18 PM2/12/16
to testng-users
Amazing support, many thanks Krishman,

Максим С

unread,
Dec 7, 2018, 3:52:59 AM12/7/18
to testng-users
Krishnan Mahadevan, you are the best. Thank you.

четверг, 11 февраля 2016 г., 5:06:44 UTC+2 пользователь Krishnan Mahadevan написал:

⇜Krishnan Mahadevan⇝

unread,
Dec 7, 2018, 4:10:28 AM12/7/18
to testng...@googlegroups.com
Thank you :) Glad to be of help. 
--
Reply all
Reply to author
Forward
0 new messages