One solution might be as follows. (I have a project that does this.)
Have a separate target similar to test
with a fileset
that restricts the test to one class only. Then pass the name of that class using -D
at the ant command line:
ant -Dtest.module=MyClassUnderTest single_test
In the build.xml (highly reduced):
<target name="single_test" depends="compile" description="Run one unit test">
<junit>
<batchtest>
<fileset dir="${test.dir}" includes="**/${test.module}.class" />
</batchtest>
</junit>
</target>