繁体   English   中英

如何在Maven和Testng中运行并行套件

[英]How to run parallel suites in maven and Testng

我想从Maven并行测试套件。 我的pom.xml如下所示:

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

所有的.xml文件都是TestNG文件,它们是Test Suites。 请让我知道如何并行运行套件。

TestNG不支持并行模式“套件”,既不通过Surefire也不通过任何运行类型的TestNG。

从文档中的命令行选项

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

该证明可以在被发现的v6.11来源XmlSuite

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

    ...
  }
  ...
}

这适用于TestNG 6.11和更低版本。

考虑将来自多个.xml文件的测试添加到具有多个<test>节点的一个.xml文件中, 并在tests testng.xml定义并行性

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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