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

http://www.51testing.com/html/36/489136-856021.html

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

 

                 HTML Report例子

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

一.需要准备的资源

ReportNG下载http://reportng.uncommons.org/,其中需要的jar为reporting.jar,velocity-dep.jar

Guice 3.0下载http://code.google.com/p/google-guice/wiki/Guice30,其中组要的jar为guice-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>

 

 

转载于:https://www.cnblogs.com/robbinluobo/p/6479225.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值