qileilove

          blog已經(jīng)轉(zhuǎn)移至github,大家請(qǐng)?jiān)L問 http://qaseven.github.io/

          使用TestNG-xslt美化測試報(bào)告

           用TestNG測試后,自動(dòng)會(huì)生成html的測試報(bào)告,不過相信大家都有感覺,自動(dòng)生成的測試報(bào)告太難看了,所以我們又用了ReportNG來美化它。在 這里給大家再介紹一下比reportNG還要稍稍美觀一點(diǎn)的reporting tool: testNG-xslt.
            其實(shí)testNG-xslt就是把testNG自動(dòng)生成的測試報(bào)告testng-results.xml進(jìn)行了一個(gè)轉(zhuǎn)換,把它的html輸出報(bào)告變得更漂亮 而已。因此用法也很簡單:
            1. 在官方網(wǎng)站上下載testNG-xslt ,http://testng-xslt.googlecode.com/files/testng-xslt-1.1.zip
            2. 解壓后把saxon-8.7.jar放到project的lib目錄下(在bulid路徑里也把這個(gè)lib加上)
            3. 然后再把/src/main/resources/testng-results.xsl放到你的 test-output 目錄下
            4. 在測試項(xiàng)目的根目錄下創(chuàng)建一個(gè)簡單的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)行這個(gè) xml 就會(huì)在test-output 目錄下生成 index1.html,打開它就是測試報(bào)告了。
            轉(zhuǎn)換前的測試報(bào)告:
            轉(zhuǎn)換后的測試報(bào)告(是不是美觀很多呢):

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

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

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 什邡市| 富锦市| 察隅县| 资溪县| 台安县| 南部县| 枞阳县| 临高县| 苏尼特左旗| 深泽县| 四子王旗| 拜泉县| 卢湾区| 信丰县| 元氏县| 禄丰县| 贞丰县| 富源县| 南澳县| 卫辉市| 洞头县| 山东| 南木林县| 灵山县| 交口县| 乌苏市| 深圳市| 新巴尔虎左旗| 咸宁市| 财经| 衡东县| 吐鲁番市| 遂川县| 三门峡市| 丁青县| 清水县| 兰州市| 大兴区| 全南县| 蛟河市| 霍州市|