ReportNG is asimple HTML reporting plug-in for the TestNG unit-testing framework. It isintended as a replacement for the default TestNG HTML report. The defaultreport is comprehensive but is not so easy to understand at-a-glance. ReportNGprovides a simple, colour-coded view of the test results.
reportng 是一个简单的testng的生成html格式报告插件,是为了取代testng默认的html report.tesng默认的report不容易理解,也不太美观。reportng提高简单的,多彩的测试结果的视图.
那么问题就来了,怎么使用?
注意:是在pom.xml文件中配置
<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>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.4</version>
</dependency>
保存后,自动开始下载资源包。
Maven Dependencies jar是否下载成功。
禁用testng default listeners
在define listener中添加:org.uncommons.reportng.HTMLReporter
最后run as test suite
在test-output>html目录就能看到漂亮的report
如果在ant里使用,需要这样 :
<testng classpathref="runpath" outputDir="test-output"
haltonfailure="true"
useDefaultListeners="false"
listeners="org.uncommons.reportng.HTMLReporter,org.testng.reporters.FailedReporter" >
<xmlfilesetdir="${basedir}" includes="Parametertestng.xml"/>
<jvmargvalue="-Dfile.encoding=UTF-8" />
<syspropertykey="org.uncommons.reportng.title" value="AutoMationTestReport" />
</testng>
Tips:以上做法方便在本地调试时使用。当你直接拿着@Test类来运行测试用例,eclipse会自动启动默认local的testng-customsuite.xml配置文件,该文件目录一般在(如图):
C:\Users\xx\AppData\Local\Temp\testng-eclipse-1200547509\testng-customsuite.xml
通过上述配置后,查看test-output文件下index.html会显示出来Reportng-Result。
但是,当你需要使用服务器来跑tesng.xml文件时,使用reportng做报告输出;那就需要通过解
析你目录下写的testng.xml和另外的配置了。
联系客服