下面将在匹配的测试上运行JUnit test/**/*Test.java。这需要junit.jar放在lib文件夹中。
<project name="Project" default="junit" basedir="."> <path id="classpath"> <fileset dir="lib" includes="**/*.jar"/> <pathelement path="build"/> </path> <target name="compile"> <javac srcdir="test" destdir="build" classpathref="classpath"/> </target> <target name="junit" depends="compile"> <junit fork="true" logfailedtests="false"> <classpath refid="classpath"/> <batchtest> <fileset dir="test" includes="**/*Test.java"/> <formatter type="plain" usefile="false"/> </batchtest> </junit> </target> </project>