gpt4 book ai didi

java - 在 pom.xml 文件并行测试中需要帮助

转载 作者:行者123 更新时间:2023-11-30 01:42:45 25 4
gpt4 key购买 nike

我有 100 个 Java 类文件用于测试。

我想将它们分成4个xml文件。(100个类分为以下xml文件)

testng1.xml
testng2.xml
testng3.xml
testng4.xml

testng.xml 文件

<suite name="MainSuite" >
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter"/>
<listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
</listeners>
<suite-files>
<suite-file path="testng1.xml" />
<suite-file path="testng2.xml" />
<suite-file path="testng3.xml" />
<suite-file path="testng4.xml" />
</suite-files>
</suite>

pom.xml 文件

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<properties>
<property>
<name>suitethreadpoolsize</name>
<value>4</value>
</property>
</properties>
</configuration>
</plugin>

执行(mvn clean test)时,它正在开始执行,但我找不到失败的地方。

我想为具有不同花色的失败和通过的类(class)生成正确的报告。

我已经尝试过ReportNG,但它没有从testng生成报告,因为我正在从POM.xml运行项目(mvn clean test)

最佳答案

您的项目中只能有一个 testNG.xml 文件因此,您可以在 xml 中定义所有测试类,然后只需提及 parallel="classes"

即可并行运行
<suite name="Test-class Suite" parallel="classes" thread-count="2" >   
<test name="Test-class test" >
<classes>
<class name="ParallelClassesTestOne" />
<class name="ParallelClassesTestTwo" />
</classes> </test>

然后您可以在 testoutput 文件夹>可通过电子邮件发送的报告中看到我们的测试结果

关于java - 在 pom.xml 文件并行测试中需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59371493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com