eclipse下使用ant进行junit4测试

<?xml version="1.0" encoding="UTF-8"?>
<project name="Hello world" default="all" basedir=".">
    <!-- property -->
    <property name="src.dir" value="src" />
    <property name="lib.dir" value="lib" />
    <property name="classes.dir" value="classes" />
    <property name="dist.dir" value="dist" />
    <property name="report.dir" value="report"></property>
    <!--classpath -->
    <path id="master-classpath">
        <fileset dir="${lib.dir}/xml">
            <include name="xml-apis.jar" />
        </fileset>
        <fileset dir="${lib.dir}/jdbc">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${lib.dir}/junit">
            <include name="**/*.jar" />
        </fileset>
    </path>
    <!--init task -->
    <target name="init"></target>
    <!--clean -->
    <target name="clean" description="clean up the output dir">
        <delete dir="${classes.dir}" />
        <delete dir="${dist.dir}" />
        <delete dir="${report.dir}" />
    </target>
    <!--compile -->
    <target name="compile" description="compile the project">
        <mkdir dir="${classes.dir}" />
        <javac srcdir="${src.dir}" destdir="${classes.dir}" target="1.5"
            debug="true">
            <classpath refid="master-classpath" />
        </javac>
        <copy todir="${classes.dir}" preservelastmodified="true">
            <fileset dir="${src.dir}">
                <include name="**/*.java" />
                <include name="**/*.properties" />
                <include name="**/*.xml" />
            </fileset>
        </copy>
    </target>
    <target name="junit" description="run junit test">
        <mkdir dir="${report.dir}" />
        <junit printsummary="true" showoutput="true"
            haltonfailure="true">
            <classpath>
                <pathelement location="${classes.dir}" />
                <fileset dir="${lib.dir}/junit">
                    <include name="**/*.jar" />
                </fileset>
            </classpath>
            <formatter type="plain" />
            <batchtest fork="true" todir="${report.dir}">
                <fileset dir="${classes.dir}">
                    <include name="**/*Test.class" />
                </fileset>
            </batchtest>
        </junit>
    </target>
    <target name="build" description="create jar file">
        <mkdir dir="${dist.dir}" />
        <jar destfile="${dist.dir}/hello.jar"
            basedir="${classes.dir}">
            <exclude name="**/*.java" />
        </jar>
    </target>
    <target name="all">
        <antcall target="clean" />
        <antcall target="compile" />
        <antcall target="junit" />
        <antcall target="build" />
    </target>
</project>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值