qileilove

          blog已經(jīng)轉(zhuǎn)移至github,大家請訪問 http://qaseven.github.io/

          使用TestNG-xslt美化測試報告

           用TestNG測試后,自動會生成html的測試報告,不過相信大家都有感覺,自動生成的測試報告太難看了,所以我們又用了ReportNG來美化它。在 這里給大家再介紹一下比reportNG還要稍稍美觀一點的reporting tool: testNG-xslt.
            其實testNG-xslt就是把testNG自動生成的測試報告testng-results.xml進(jìn)行了一個轉(zhuǎn)換,把它的html輸出報告變得更漂亮 而已。因此用法也很簡單:
            1. 在官方網(wǎng)站上下載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. 在測試項目的根目錄下創(chuàng)建一個簡單的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 運(yùn)行這個 xml 就會在test-output 目錄下生成 index1.html,打開它就是測試報告了。
            轉(zhuǎn)換前的測試報告:
            轉(zhuǎn)換后的測試報告(是不是美觀很多呢):

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

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

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 北宁市| 中阳县| 同心县| 宁安市| 巴马| 梨树县| 易门县| 平乡县| 雷山县| 荃湾区| 建昌县| 洛阳市| 津市市| 怀集县| 田林县| 正安县| 宾阳县| 醴陵市| 三台县| 光山县| 彰武县| 余庆县| 鹿邑县| 宁河县| 佛教| 阳西县| 邯郸市| 德庆县| 孟连| 曲松县| 乌拉特前旗| 江阴市| 曲麻莱县| 丽江市| 乐都县| 积石山| 秦皇岛市| 霍林郭勒市| 溧阳市| 政和县| 南昌县|