Ant中批量调用TestNG的XML文件,并调用TestNgXlst生成漂亮的html测试报告

1、在Ant中设置如下:

    <target name="run_tests">    
        <testng classpathref="classpath.main"                
                failureproperty="test.failed">            
            <!--此目录下的所有TestNG的XML文件,使用*号表示此目录下所有 -->
            <xmlfileset dir="${suite.dir}">
               	<include name="*.xml"/>
            </xmlfileset>                        
        </testng>
    	
    	<!--TestNG执行完毕后,根据输出的testng-results.xml文件,按照testng-results.xsl的设定生成html格式的测试报告 -->
    	
		<echo taskname="OutputReport" message="start output report" />
		<xslt in="${test-output.dir}/testng-results.xml" style="${testNgXslt.dir}/config/testng-results.xsl" out="${testNgXslt.dir}/out/${CURTIME}/index.html">
			<param name="testNgXslt.outputDir" expression="${testNgXslt.dir}/out/${CURTIME}"/>
			<param name="testNgXslt.showRuntimeTotals" expression="true"/>
			<classpath refid="classpath.main"/>
		</xslt>  
    	
    </target>


在上述配置中,${testNgXslt.dir}/out/${CURTIME}表示测试报告输出的目录,${CURTIME}是根据测试执行时间标识,按照年月日时分秒格式。如下:

	<tstamp>   
		<format property="CURTIME" pattern="yyyyMMddHHmmss" locale="us"/>   
	</tstamp>   




posted on 2012-08-14 15:30  bwgang  阅读(357)  评论(0编辑  收藏  举报

导航