Sarada Akurathi
Sarada Akurathi

Reputation: 1198

How to run parallel suites in maven and Testng

I want to the Test Suites parallel from maven. my pom.xml looks like below:

<profiles>
        <profile>
            <id>API_AUTOMATION</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.19.1</version>
                        <configuration>
                            <parallel>suites</parallel>
                            <threadCount>8</threadCount>
                            <suiteXmlFiles>
                                <!-- TestNG suite XML files -->
                                <suiteXmlFile>./module1.xml</suiteXmlFile>                              
                             <suiteXmlFile>./module2.xml</suiteXmlFile>
                            </suiteXmlFiles>
                            <testSourceDirectory>src/main/java</testSourceDirectory>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
</profiles>

all the .xml files are TestNG file which are Test Suites. please let me know, how to run the suites in parallel.

Upvotes: 0

Views: 3391

Answers (2)

Murthi
Murthi

Reputation: 5347

You can try with <threadCountSuites>8</threadCountSuites> property and don't set thread count property or set it as 0.

Upvotes: 2

try-catch-finally
try-catch-finally

Reputation: 7634

Parallelmode "suites" is not supported by TestNG, neither via Surefire nor through any run type of TestNG.

From the command line options in the documentation:

-parallel    methods|tests|classes    If specified, sets the default 
                                      mechanism used to determine how 
                                      to use parallel threads when 
                                      running tests. If not set, 
                                      default mechanism is not to use 
                                      parallel threads at all. This can 
                                      be overridden in the suite 
                                      definition.

The proof can be found in the v6.11 sources of XmlSuite:

public class XmlSuite implements Serializable, Cloneable {
  /** Parallel modes */
  public enum ParallelMode {
    TESTS("tests", false), METHODS("methods"), CLASSES("classes"), INSTANCES("instances"), NONE("none", false),

    ...
  }
  ...
}

This applies to TestNG 6.11 and older versions.

Consider adding the tests from multiple .xml files into one .xml file with multiple <test> nodes and define the parallelism in the testng.xml to be tests.

Upvotes: 1

Related Questions