TestNG之使用ReportNG生成测试报告

TestNG使用ReportNG生成测试报告会更加美观。

  • 依赖包
 1  <!--testNG报告依赖包-->
 2         <dependency>
 3             <groupId>org.testng</groupId>
 4             <artifactId>testng</artifactId>
 5             <version>6.14.3</version>
 6             <scope>test</scope>
 7         </dependency>
 8         <dependency>
 9             <groupId>org.uncommons</groupId>
10             <artifactId>reportng</artifactId>
11             <version>1.1.4</version>
12             <scope>test</scope>
13         </dependency>
14         <dependency>
15             <groupId>com.google.inject</groupId>
16             <artifactId>guice</artifactId>
17             <version>4.2.2</version>
18         </dependency>
  • 构建配置

监听名:org.uncommons.reportng.HTMLReporter

  • TestNG.xml配置
<suite>

     ...

   <listeners>
        <!--testng的XML配置文件中添加这些内容-->
        <listener class-name="org.uncommons.reportng.HTMLReporter"/>
        <listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
    </listeners>

</suite>
  • 报告样式举例

./test-output/html/index.html

 

原文地址:https://www.cnblogs.com/gongxr/p/10345298.html