How to run JUnit tests suite in Ant?

Solution 1:

Position the classpath like below

<target name="TestSuite">
<mkdir dir="${junit}"/>
<junit fork="yes" printsummary="withOutAndErr">
    <sysproperty key="variable" value="${value}"/>
    <formatter type="xml"/>

  <classpath refid="Tests.classpath"/>
    <batchtest todir="${junit}">
  <fileset dir="src">
         <include name="**/TestSuite.class"/>
      </fileset>
    </batchtest>

</junit>