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