Skip to content

Instantly share code, notes, and snippets.

@brianjriddle
Created July 25, 2013 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianjriddle/6078705 to your computer and use it in GitHub Desktop.
Save brianjriddle/6078705 to your computer and use it in GitHub Desktop.
ant task to run all the tests or only one test. You'll need to supply the properties where to find your test source, libs and what not. Mainly here so i don't have to look this up again because it's not often need to do this but ant's as poorly written as this sentence.
<target name="run-tests" depends="compile">
<junit failureproperty="test.failure" includeantruntime="false">
<classpath refid="run.classpath"/>
<formatter type="plain" usefile="no"/>
<batchtest todir="${reports.dir}" unless="test">
<fileset dir="${source.dir}" includes="**/*Test.java"/>
<formatter type="xml"/>
</batchtest>
<!-- if you only want to run *one* test use
ant run-tests -Dtest=Classname
-->
<batchtest todir="${reports.dir}" if="test">
<fileset dir="${source.dir}" includes="**/${test}.java"/>
</batchtest>
</junit>
<fail message="One or more test cases failed" if="test.failure"/>
</target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment