使用Ant自动生成Junit测试报告

<?xml version = "1.0" encoding = "UTF-8" ?>
<project name="IHDS" default="test" basedir=".">
    <property name="src.dir" location="src" />
    <property name="tests.dir" location="test" />
    <property name="classes.dir" location="build/classes" />
    <property name="lib" location="WebContent/WEB-INF/lib" />
 
    <property name="report"   value="report"/>
    <property name="report.xml" value="${report}/junit/xml"/>
    <property name="report.html" value="${report}/junit/html"/>
 
    <property environment="env"/>
    <property name="tomcat.home" value="${env.CATALINA_HOME}"/>
 
    <path id="compile.classpath">
        <fileset dir="${lib}" includes="*.jar"/><!--excludes="" -->
        <fileset dir="${tomcat.home}/lib" includes="*.jar" />
    </path>
 
    <path id="test.classpath">
        <path refid="compile.classpath"/>
        <pathelement location="${classes.dir}"/>
    </path>
 
    <target name="init">
        <delete dir="${report}"/>
        <delete dir="${classes.dir}"/>
    </target>
 
    <target name="compile" depends="init" description="Compile Java code">
        <mkdir dir="${classes.dir}" />
        <javac srcdir="${src.dir}" destdir="${classes.dir}" >
            <classpath refid="compile.classpath"/>
        </javac>
        <copy todir="${classes.dir}">
            <fileset dir="${src.dir}">
                <include name="**/*.xml" />
                <include name="**/*.properties" />
            </fileset>
        </copy>
    </target>
 
    <target name="compile-tests" depends="compile" description="Compile Unit Tests">
        <javac srcdir="${tests.dir}" destdir="${classes.dir}">
            <classpath refid="test.classpath"/>
        </javac>
    </target>
 
    <target name="test" depends="compile-tests"  description="Run unit tests">
        <mkdir dir="${report.xml}"/>
        <mkdir dir="${report.html}"/>
 
        <junit printsummary="yes" haltonfailure="no">
            <classpath refid="test.classpath" />
            <formatter type="xml"/>
            <batchtest fork="yes" todir="${report.xml}">
                <fileset dir="${tests.dir}">
                    <include name="**/*Test.java" />
                	<exclude name="cn/aug/action/BaseTest.java"/>
                </fileset>
            </batchtest>
        </junit>
 
        <junitreport todir="${report.html}">
            <fileset dir="${report.xml}">
                <include name="*.xml"/>
            </fileset>
            <report format="frames" todir="${report.html}"/>
        </junitreport>
    </target>
</project>

 

posted on 2012-04-29 18:41 xliujingweix 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/xliujingweix/archive/2012/04/29/2476307.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值