使用TestNG-xslt+ant来美化selenium测试报告

一.背景
1.如果使用junit开发selenium测试案例,可以使用JUnit Report来生成报告
2.如果使用testNG开发selenium测试案例,不需要做额外的来产生测试报告,它会产生一个html格式的报告.
3.ReprotNG是一个testNG测试框架的插件,它可以替代默认的testNG HTML测试报告.ReprotNG提供了一个简单彩色编码测试报告试图.
4.要想获得一个非常好的总结测试报告,试一下TestNg-xslt。

二.选择TestNG-xslt生成测试报告
1,下载testng-xslt-1.1.zip
2,解压testng-xslt-1.1.zip把saxon-8.7.jar放到项目的lib目录下面,并引入到项目中
3,把testng-xslt-1.1\src\main\resources下的testng-results.xsl放到项目的src下.
4,在项目上新建test-output文件夹,并把testng-results.xsl和testng-results.xml文件放到此文件夹下.
5,在项目src下新建build.xml

<?xml version="1.0" encoding="GBK"?>
<project name="selenium" basedir="." default="transform">
    <!-- 项目引用库文件的目录我的是C:\Users\zhangxiaoding\workspace\TestGome\Tools -->
  <property name= "lib.dir" value= "D:\workspace\selenium\WebContent\WEB-INF\lib" />
<path id= "test.classpath" >
<!-- adding the saxon jar to your classpath -->
<fileset dir= "${lib.dir}" includes= "*.jar" />
</path>
<target name= "transform" >
<xslt in= "D:/workspace/selenium/test-output/testng-results.xml" style= "D:/workspace/selenium/test-output/testng-results.xsl"
<!-- 生成的报告html文件的目录我的是C:/Users/zhangxiaoding/workspace/TestGome/test-output/index1.html -->
out= "D:\workspace\selenium\test-output\index1.html " >
<!-- you need to specify the directory here again -->
<!-- 下述目录同上 -->
<param name= "testNgXslt.outputDir" expression= "D:\workspace\selenium\test-output" />
<classpath refid= "test.classpath" />
</xslt>
</target>
</project>

6,最后用 ant 运行这个 xml 就会在test-output 目录下生成 index1.html,打开它就是测试报告了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

慕城南风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值