Failing the Build if JUnit is Missing

The build scripts generated by the Ant Plugin require JUnit to run the unit tests. By default, the build.xml will only output a warning if JUnit was not found on the class path, i.e. the build simply continues without running the unit tests. If you rather want the build to fail in this case, you can easily customize the build.xml by overriding the target junit-missing :

<?xml version="1.0" encoding="UTF-8"?>

<!-- ====================================================================== -->
<!-- Ant build file ( for Ant 1.6.2 or above.        -->
<!-- ====================================================================== -->

<project name="%PROJECT_ARTIFACT_ID%" default="package" basedir=".">

  <!-- ====================================================================== -->
  <!-- Unit testing, overridden to fail upon missing JUnit                    -->
  <!-- ====================================================================== -->

  <target name="junit-missing"
    <property name="ant.libdir" location="${ant.home}/lib"/>
    <echo level="error">==================================== ERROR ====================================</echo>
    <echo level="error"> JUnit is not present in your $ANT_HOME/lib directory, aborting build.         </echo>
    <echo level="error"> Please copy "junit.jar" to "${ant.libdir}".                                   </echo>
    <echo level="error">===============================================================================</echo>
    <fail>JUnit not found on class path, cannot run unit tests.</fail>