qileilove

          blog已經轉移至github,大家請訪問 http://qaseven.github.io/

          使用TestNG-xslt美化測試報告

           用TestNG測試后,自動會生成html的測試報告,不過相信大家都有感覺,自動生成的測試報告太難看了,所以我們又用了ReportNG來美化它。在 這里給大家再介紹一下比reportNG還要稍稍美觀一點的reporting tool: testNG-xslt.
            其實testNG-xslt就是把testNG自動生成的測試報告testng-results.xml進行了一個轉換,把它的html輸出報告變得更漂亮 而已。因此用法也很簡單:
            1. 在官方網站上下載testNG-xslt ,http://testng-xslt.googlecode.com/files/testng-xslt-1.1.zip
            2. 解壓后把saxon-8.7.jar放到project的lib目錄下(在bulid路徑里也把這個lib加上)
            3. 然后再把/src/main/resources/testng-results.xsl放到你的 test-output 目錄下
            4. 在測試項目的根目錄下創建一個簡單的build.xml, 如下:
          <?xml version="1.0" encoding="UTF-8"?>
          <project name= "testTng" basedir= "." default="transform">
          <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= "G:/eclipse3.7/workspace/testTng/test-output/testng-results.xml" style= "G:/eclipse3.7/workspace/testTng/test-output/testng-results.xsl"
          out= "G:\eclipse3.7\workspace\testTng\test-output\index1.html " >
          <!-- you need to specify the directory here again -->
          <param name= "testNgXslt.outputDir" expression= "G:\eclipse3.7\workspace\testTng\test-output" />
          <classpath refid= "test.classpath" />
          </xslt>
          </target>
          </project>
            5.最后用 ant 運行這個 xml 就會在test-output 目錄下生成 index1.html,打開它就是測試報告了。
            轉換前的測試報告:
            轉換后的測試報告(是不是美觀很多呢):

          posted on 2014-08-14 09:25 順其自然EVO 閱讀(1824) 評論(0)  編輯  收藏 所屬分類: 測試學習專欄

          <2014年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 棋牌| 南岸区| 屏边| 宁晋县| 开鲁县| 浮山县| 色达县| 济源市| 蕉岭县| 静安区| 盐津县| 焉耆| 达孜县| 深泽县| 绥芬河市| 弥勒县| 临澧县| 临高县| 阿图什市| 沛县| 务川| 云南省| 砀山县| 达拉特旗| 西畴县| 临沂市| 岳普湖县| 潜江市| 吴桥县| 麻江县| 盐城市| 益阳市| 麦盖提县| 凤台县| 阿克苏市| 锡林郭勒盟| 太和县| 新安县| 龙里县| 砚山县| 南川市|