使用ReportNG为TestNG提供更好的测试报告

上一篇 / 下一篇  2013-12-31 14:27:03 / 个人分类:自动化测试


ReportNGTestNG单元测试框架的一个HTML报表生成插件。它用于替换TestNG默认的HTML报表,其默认的报表虽然信息全面,但不易于理解。ReportNG提供一种简单的方式来查看测试结果,并能够对结果代码进行着色。还可以通过修改CSS文件来替换默认的输出样式。此外ReportNG还能够生成JUnit格式的XML输出。


                 HTML Report例子

下面来介绍一下如何在Eclipse中以及Ant build.xml中进行配置的过程。

一.需要准备的资源

ReportNG下载http://reportng.uncommons.org/其中需要的jarreporting.jarvelocity-dep.jar

Guice 3.0下载http://code.google.com/p/google-guice/wiki/Guice30其中组要的jarguice-3.0.jar

将上述的jar文件添加到你的build path

二.Eclipse中的配置

1.      进入Poperties-> TestNG

2.      选中Disable default listeners

3.      Pre Defined Listeners中输入你需要的,org.uncommons.reportng.HTMLReporter用来生成HTML格式的,org.uncommons.reportng.JUnitXMLReporter则会输出JUnit格式的,当然也可以两者都用


三.Ant build.xml中的配置

道理同上,在build.xml中添加红色字体的部分,既可以完成ReportNG的配置

<taskdef resource="testngtasks" classpath="${lib}/testng-6.8.jar" />    

<target name="run" depends="build" >    

<testng classpathref="classpath"

       useDefaultListeners="false"

listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter"

       outputdir="${report}/${nowstamp}"

       failureproperty="test.failed">    

<xmlfileset dir="${suite}">

</xmlfileset>

</testng>


TAG:

maplee的个人空间 引用 删除 maplee   /   2017-03-07 18:16:33
5
 

评分:0

我来说两句

Open Toolbar