zoukankan      html  css  js  c++  java
  • ant+TestNGxslt生成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 执行后的状态来过滤查询等等。

     

  • 相关阅读:
    Get distinct count of rows in the DataSet
    单引号双引号的html转义符
    PETS Public English Test System
    Code 39 basics (39条形码原理)
    Index was outside the bounds of the array ,LocalReport.Render
    Thread was being aborted Errors
    Reportviewer Error: ASP.NET session has expired
    ReportDataSource 值不在预期的范围内
    .NET/FCL 2.0在Serialization方面的增强
    Perl像C一样强大,像awk、sed等脚本描述语言一样方便。
  • 原文地址:https://www.cnblogs.com/zhangfei/p/2076163.html
Copyright © 2011-2022 走看看