使用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) 編輯 收藏 所屬分類: 測試學習專欄