ant+TestNG-xslt生成selenium测试报告

使用 selenium+testng 做自动化测试的时候,生成的测试报告比较难看,也不是很实用。 怎样才能生成我们想要的报告呢。使用 TestNG-xslt 这个插件可以生成较理想的报告。

       我们现在使用 testng 跑完测试后,会在测试代码的根目录下生成一个文件夹 test-output ,里面有 testng 生成的测试报告,也就是我们要改进的测试报告。

在 testng 生成的文件中有一个 testng-results.xml ,这里面有我们的测试结果信息。 TestNG-xslt 要做的工作就是把这个文件里面的信息重新表现。下面我们通过这 个插件来重新生成我们的测试报告。

1.    下载 TestNG-xslt 把 saxon-8.7.jar 复制到测试项目的 lib 下

2.    然后在测试项目的根目录下添加 build.xml

<project name= "myproject" basedir= "." >

    <property name= "lib.dir" value= "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:/tmsTest/SeleniumTest0809/test-output/testng-results.xml" style= "D:/tmsTest/SeleniumTest0809/test-output/testng-results.xsl"

  out= "D:/tmsTest/SeleniumTest0809/test-output/ index1.html " >

             <!-- you need to specify the directory here again -->

            <param name= "testNgXslt.outputDir" expression= "D:/tmsTest/SeleniumTest0809/test-output/" />

            <classpath refid= "test.classpath" />

        </xslt>

    </target>

</project>

3. 从你下载的包中拷贝文件 testng-results.xsl 到 test-output 目录下。 testng-results.xsl 文件的位置是 testng-xslt-1.1.1\src\main\resources ,为什么要这个文件呢?因为我们的测试报告就是用这个 style 生成的。

4. 用 ant 运行这个 xml 就会在 test-output 目录下生成 index1.html , 打开它就能看到新生成的测试报告 , 通过生成的报告我们能看到总体的情况,比如通过了多少 case ,失败了多少,跳过了多少没执行。第二个好处是我们可以查看失败的 case 抛出的异常,有具 体的函数和行号。我们还可以通过 case 执行后的状态来过滤查询等等。

 

转载于:https://www.cnblogs.com/zhangfei/archive/2011/06/09/2076163.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值