title: Can't get Ant to run my JUnit test
body: <p>I have created an Ant target to compile my code.</p>
  
  <pre><code>&lt;target name="test" depends="compile"&gt;
      &lt;junit&gt;
          &lt;classpath&gt;
              &lt;pathelement path="${basedir}\..\SwaCore\lib\junit.jar"/&gt;
          &lt;/classpath&gt;
          &lt;classpath&gt;
              &lt;pathelement path="${build}"/&gt;
          &lt;/classpath&gt;
          &lt;test name="BinarySearchTest" /&gt;
      &lt;/junit&gt;
  &lt;/target&gt;
  
  &lt;target name="compile"&gt;
      &lt;mkdir dir="${build}"/&gt;
      &lt;javac
          srcdir="${basedir}\src;${basedir}\..\SwaCore\src;${basedir}\..\SwaShared\src;${basedir}\..\SwaDictionary\src;${basedir}\..\SwaSuggestion\src;${basedir}\..\SwaServerSharedCore\src;${basedir}\..\SwaPrediction\src;"
          destdir="${build}"
          debug="true"
          debuglevel="lines,vars,source"&gt;
          &lt;classpath&gt;
              &lt;pathelement path="${basedir}\..\SwaCore\lib\junit.jar"/&gt;
              &lt;pathelement path="${basedir}\..\SwaSuggestion\lib\ssce.jar"/&gt;
              &lt;pathelement path="C:\Java\javamail-1.4.1\mail.jar"/&gt;
              &lt;pathelement path="C:\Java\commons-net-2.0\commons-net-ftp-2.0.jar"/&gt;
              &lt;pathelement path="${basedir}\WebContent\WEB-INF\lib\gson-2.2.1.jar"/&gt;
              &lt;pathelement path="${tomcatLibs}\servlet-api.jar"/&gt;
          &lt;/classpath&gt;
      &lt;/javac&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>The compile works fine, all my classes are in the folder pointed to by ${build}.  I assume this ${build} will be the classpath for my JUnit test case.
  I then have a test target that I want to run a JUnit test Called BinarySearchTest. When I run this I get the simple error</p>
  
  <pre><code>Test BinarySearchTest FAILED
  </code></pre>
  
  <p>I know my Unit test is ok because it tests nothing. </p>
  
  <pre><code>public class BinarySearchTest extends TestCase
  {
      public void test()
      {       
      }
  }
  </code></pre>
  
  <p>Even if I put the following in my test target I still get the same error</p>
  
  <pre><code>&lt;test name="AtestThatDoesNotExistTest" /&gt;
  </code></pre>
  
  <p>result = </p>
  
  <pre><code>Test AtestThatDoesNotExistTest FAILED
  </code></pre>
  
  <p>I would have expected a classNotFound error so there is obviously something fundamentally wrong with my Ant XML</p>
  
  <p>JUnit jar is being picked up ok because if it's not in the classpath I will get the error </p>
  
  <pre><code>The &lt;classpath&gt; for &lt;junit&gt; must include junit.jar if not in Ant's own classpath
  </code></pre>
  
  <hr>
  
  <p>Update
  I modified my target to include</p>
  
  <pre><code>        &lt;formatter type="brief" usefile="false" /&gt;
          &lt;test name="com.swaserver.junit.BinarySearchTest" /&gt;
  
  test:
  [junit] Testsuite: com.swaserver.junit.BinarySearchTest
  [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.878 sec
  [junit] ------------- Standard Output ---------------
  [junit] Initializing Binary search class
  [junit] Binary search class initialized
  [junit] ------------- ---------------- ---------------
  </code></pre>
  
  <p>BUILD SUCCESSFUL
  Total time: 2 seconds</p>
  
  <p>Now I can see that my test is actually run.  However I get a class not found unless I specify the fully qualified class name for my unit test. Why would this be?  </p>