“1.1.4版本的ReportNG是最后一个版本,之后不再做维护。作为一个简单的测试报告插件,它是创造来替代TestNG原有的HTML报告。ReportNG提供了一个简易的、色彩分明的测试结果报告”,这段话是reportng官网上的介绍。(引自:https://www.cnblogs.com/chengtch/p/6071322.html)
对比testng自带报告和ReportNG生成的测试报告:reportNg生成的报告有统计通过概率。
步骤:
1. 添加pom.xml相关配置
<!-- 依赖reportNg 关联testNg-->
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 添加插件,添加ReportNg的监听器,修改最后的TestNg的报告 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<properties>
<property>
<name>usedefaultlisteners</name>
<!--刚开始这里没有设置默认监听false,所以没有启用reportNG功能。-->
<value>true</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
<workingDirectory>target/</workingDirectory>
<forkMode>always</forkMode>
</configuration>
</plugin>
2. 配置IDEA
亲测可用,参考 https://blog.csdn.net/weixin_34297704/article/details/86474680
方法二, 设置testng.xml,可参考以上地址
3. 执行testng.xml, 生成reportng HTML测试报告
e.g.