ant Run JUnit


Example

The following will run JUnit on the tests matching test/**/*Test.java. This need the junit.jar to be in the lib folder.

<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>