简体   繁体   中英

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.

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 .

您可以尝试使用<threadCountSuites>8</threadCountSuites>属性,而不设置线程计数属性或将其设置为0。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM