13. TestNG報告
默認報告輸出位置為當前工程的test-output文件夾下,包括xml格式和html格式。
如果想要美化報告,則按照如下步驟:
1、配置:Eclipse --> Window --> Preferences -->testng
2、勾選Disable default listeners
3、在Pre Defined Listeners 輸入框中輸入org.uncommons.reportng.HTMLReporter
記得在POM上添加如下代碼:
```
<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>
? ? ?<dependency>
? ? ? ?<groupId>com.google.inject</groupId>
? ? ? ?<artifactId>guice</artifactId>
? ? ? ?<version>3.0</version>
? ? ? ?<scope>test</scope>
? ? ?</dependency>
```
不然無法運行的。
如上圖所示,還可以自定義testng.xml的模板,并在上圖中指定。
使用IDEA+TestNG進行測試,沒有生成 測試報告,是因為沒有勾選監聽器使用默認報告,具體操作如下:
“Run” -> "Edit Configurations"?-> "listeners"?-> "Use default reporters"
輸出報告在test-output文件夾中(index.html)。