使用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í)專欄