junit与ant整合的build.xml的编写-----非常重要,看懂这个,你就懂了ant的90%了




<?xml version="1.0" encoding="UTF-8"?>
<project name="junit-test">
 <property name="src.dir" location="src"></property>
 <property name="test.src.dir" location="test"></property>
 <property name="lib.dir" location="lib"></property>
 <property name="build.dir" location="build"></property>
 <property name="build.classes" location="${build.dir}/classes"></property>
 <property name="build.test.dir" location="${build.dir}/test"></property>
 <property name="build.test.classes" location="${build.test.dir}/classes"></property>
 <property name="build.test.report" location="${build.test.dir}/report"></property>

 <property name="run.test.class" value="**/Test*.class"></property>
 
 <path id="compile-path">
  <fileset dir="${lib.dir}" includes="*.jar"></fileset>
 </path>
 
 <path id="compile-test-path">
  <path refid="compile-path"></path>
  <pathelement location="${build.classes}"/>
 </path>
 
 <path id="run-test-path">
  <path refid="compile-test-path"></path>
  <pathelement location="${build.test.classes}"/>
 </path>
 
 <target name="clean">
  <echo>进行项目的清理工作</echo>
  <delete dir="${build.dir}"></delete>
 </target>
 
 <target name="init">
  <echo>进行项目的初始化</echo>
  <mkdir dir="${build.dir}"/>
  <mkdir dir="${build.classes}"/>
  <mkdir dir="${build.test.dir}"/>
  <mkdir dir="${build.test.classes}"/>
  <mkdir dir="${build.test.report}"/>
 </target>
 
 <target name="compile" depends="init">
  <echo>编译源文件</echo>
  <javac failοnerrοr="true" includeantruntime="true" srcdir="${src.dir}" destdir="${build.classes}" classpathref="compile-path"></javac>
 </target>
 
 <target name="compile-test" depends="compile">
  <echo>编译测试文件</echo>
  <javac failοnerrοr="true" includeantruntime="true" srcdir="${test.src.dir}" destdir="${build.test.classes}" classpathref="compile-test-path"/>
 </target>
 
 <target name="run-test" depends="compile-test">
  <echo>运行单元测试</echo>
  <junit printsummary="false" haltonfailure="false">
   <classpath refid="run-test-path"></classpath>
   <formatter type="brief" usefile="false"/>
   <!--<test name="${run.test.class}"></test>-->
   <formatter type="xml"/>
   <batchtest todir="${build.test.report}">
    <fileset dir="${build.test.classes}" includes="${run.test.class}"></fileset>
   </batchtest>
  </junit>
  <junitreport todir="${build.test.report}">
   <fileset dir="${build.test.report}" includes="TEST-*.xml"></fileset>
   <report format="frames" todir="${build.test.report}/html"/>
  </junitreport>
 </target>
 
 <target name="end" depends="run-test">
  <echo>整个过程结束</echo>
 </target>
</project>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值