testng报告美化的方法

上一篇 / 下一篇  2013-04-27 15:57:24 / 个人分类:TestNG

需要用到ant工具
testng报告美化的方法 
1.下载 TestNG-xslt 把 saxon-8.7.jar 
2.复制到测试项目的 lib 下
3. 从你下载的包中拷贝文件 testng-results.xsl 到 test-output 目录下
testng-results.xsl 文件的位置是testng-xslt-1.1.1/src/main/resources 
为什么要这个文件呢,因为我们的测试报告就是用这个 style. 生成的。 
4.在上面的build.xml中将第二行的写成default="testoutput"即可

build.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- -->
<project basedir="." default="testoutput" name="AMS">
<!--项目目录-->
<property name="base.dir" value="E:/workspace/AMS"/>
<property name="lib.dir" value="${base.dir}/lib"/>
<property name="testng.output.dir" value="${base.dir}/test-output"/>
<!--testng文件目录-->
<property name="testsuit.dir" value="${base.dir}/src/com/gateway/testsuit"/>
<property name="testng.file" value="test.xml"/>
<taskdef resource="testngtasks" classpath="${lib.dir}/testng.jar"/>
<target name="clean">
<delete dir="${base.dir}/bin"/>
</target>
<target name="compile" depends="clean">
<mkdir dir="${base.dir}/bin"/>
<javac srcdir="${base.dir}/src" encoding="utf-8" destdir="${base.dir}/bin" classpathref="classes" includeantruntime="off"
      debug="on" debuglevel="lines,vars,source"/>
</target>
<!--依赖的jar包地址-->
<path id="classes">
<fileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="${lib.dir}" includes="*.zip"/>
<pathelement location="${base.dir}/bin"/>
</path>
<target name="runtest" depends="compile">
<testng utputdir="${testng.output.dir}" classpathref="classes" 
delegateCommandSystemProperties="true">
<!--测试套地址和文件 -->
<xmlfileset dir="${testsuit.dir}" includes="${testng.file}"/>
<xmlfileset dir="${testsuit.dir}" includes="${testngA.file}"/>
</testng>
</target>
<path id="test.classpath">
<fileset dir="${lib.dir}" includes="*.jar"></fileset>
</path>
<!--testng 测试结果美化包,不用的话,将第二行的default="testoutput"改为default="runtest"-->
 <target name="testoutput" depends="runtest"> <xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/test-output/testng-results.xsl" ut="${basedir}/test-output/index1.html"> <!-- you need to specify the directory here again --> <param name="testNgXslt.outputDir" expression="${basedir}/test-output/" /> <classpath refid="test.classpath" /> </xslt> <fail message="ERROR: test failed!!!!!" if="test.failed" /> </target>
</project>


TAG: 美化包 Ant TestNG

 

评分:0

我来说两句

Open Toolbar