【问题标题】:TestNG - parallel executing Test SuitesTestNG - 并行执行测试套件
【发布时间】:2019-02-01 19:58:18
【问题描述】:

有 4 个类有测试 TestClass1, TestClasss2, TestClass3, TestClass4。您需要创建 2 个测试套件,每个测试套件将包含 2 个类并使用 Maven surefire plugin 并行运行它们。

我创建了 2 个 xml 文件,内容如下:

<suite name="TestSuite" verbose="1">
    <test name="Test">
        <classes>
            <class name="Tests.TestClass1">
            </class>
            <class name="Tests.TestClass2">
            </class>
        </classes>
    </test>
</suite>

和

<suite name="TestSuite1" verbose="1">
    <test name="Test1">
        <classes>
            <class name="Tests.TestClass3">
            </class>
            <class name="Tests.TestClass4">
            </class>
        </classes>
    </test>
</suite>

还添加到pom.xml inmaven-surefire-plugin 以下:

<configuration>
       <suiteXmlFiles>
           <suiteXmlFile>Testng.xml</suiteXmlFile>
           <suiteXmlFile>Testng1.xml</suiteXmlFile>
       </suiteXmlFiles>
       <parallel>suite</parallel>
       <perCoreThreadCount>false</perCoreThreadCount>
       <threadCount>2</threadCount>
</configuration>

接下来,我使用命令mvn clean test 运行项目,项目将要运行,但测试没有启动。我哪里错了?

更新:

项目正在构建,但测试未开始

文件 testng.xml 位于根文件夹中

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.469 sec - in T
estSuite

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.288 s
[INFO] Finished at: 2018-08-27T15:52:21+03:00
[INFO] ------------------------------------------------------------------------

【问题讨论】:

  • 如果可用,请分享错误日志,并确保 Testng.xml 文件位于正确的位置。上述代码中,假设Testng.xml在项目根目录下
  • 更新描述
  • 顺便说一句。如果您没有在 pom.xml 中指定 xmlSuiteFile 的路径 - 没有错误。项目构建正确通过
  • 错误似乎有所不同,在依赖管理或万无一失的地方出现错误,这与 testng.xml 无关。请参考stackoverflow.com/questions/36427868/… 并确保没有缺少依赖项
  • 我更新了我的maven插件,这个问题就解决了。但现在我遇到了下一个。看,请更新

标签: maven selenium-webdriver testng maven-surefire-plugin


【解决方案1】:

试试下面的配置:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.0</version>
    <configuration>
        <suiteXmlFiles>
            <file>src/test/resources/testng.xml</file>
            <file>src/test/resources/testng1.xml</file>
        </suiteXmlFiles>
        <properties>
            <property>
                <name>suitethreadpoolsize</name>
                <value>2</value>
            </property>
            <property>
                <name>surefire.testng.verbose</name>
                <value>10</value>
            </property>
        </properties>
    </configuration>
</plugin>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-04
    • 1970-01-01
    • 1970-01-01
    • 2020-08-30
    • 2015-11-25
    相关资源
    最近更新 更多