Ant 与 JUnit 结合的一个例子 <project name="junitSample" default="test"> <target name="init"> <property name="outdir" value="/home/AD/temp/junitSample"/> <property name="reportdir" value="./report/html"/> </target> <target name="prepare" depends="init"> <mkdir dir="${outdir}"/> <mkdir dir="${reportdir}"/> </target> <target name="compile" depends="prepare"> <javac srcdir="./src" destdir="${outdir}" classpath="junit.jar"/> </target> <target name="test" depends="compile"> <junit printsummary="true"> <formatter type="xml"/> <formatter type="plain"/> <test name="junit.samples.AllTests"/> <test name="xptoolkit.junit.example.HashMapTest"/> <classpath> <pathelement location="${outdir}"/> </classpath> </junit> <junitreport todir="./report"> <fileset dir="."> <include name="TEST-*.xml"/> </fileset> <report format="frames" todir="${reportdir}"/> </junitreport> </target></project>