title: Yet another Ant + JUnit classpath problem
body: <p>I'm developing an Eclipse SWT application using Eclipse. There are also some JUnit 4 tests, which test some DAO's. But when I try to run the tests via an ant build, all of the tests fail, because the test classes aren't found.</p>
  
  <p>Google brought up about a million of people who all have the same problem, but none of their solutions seem to work for me -.- . </p>
  
  <p>These are the contents of my build.xml file:</p>
  
  <pre><code>&lt;property name="test.reports" value="./test/reports" /&gt;
  &lt;property name="classes" value="build" /&gt;
  
  
  &lt;path id="project.classpath"&gt;
      &lt;pathelement location="${classes}" /&gt;
  &lt;/path&gt;
  
  &lt;target name="testreport"&gt;
      &lt;mkdir dir="${test.reports}" /&gt;
      &lt;junit fork="yes" printsummary="no" haltonfailure="no"&gt;
          &lt;batchtest fork="yes" todir="${test.reports}" &gt;
              &lt;fileset dir="${classes}"&gt;
                  &lt;include name="**/Test*.class" /&gt;
              &lt;/fileset&gt;
          &lt;/batchtest&gt;
          &lt;formatter type="xml" /&gt;
  
          &lt;classpath refid="project.classpath" /&gt;
  
  
      &lt;/junit&gt;
  
      &lt;junitreport todir="${test.reports}"&gt;
          &lt;fileset dir="${test.reports}"&gt;
              &lt;include name="TEST-*.xml" /&gt;
          &lt;/fileset&gt;
          &lt;report todir="${test.reports}" /&gt;
      &lt;/junitreport&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>The test classes are in the build-directory together with the application classes, although they are in some subfolders according to their packages.</p>
  
  <p>Maybe this is important too: At first Ant complained that JUnit wasn't in its classpath, but since I put it there (with the eclipse configuration editor) it complains about JUnit being in its classpath twice.</p>
  
  <pre><code>WARNING: multiple versions of ant detected in path for junit 
     [junit]          jar:file:C:/Users/as df/Documents/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib/ant.jar!/org/apache/tools/ant/Project.class
     [junit]      and jar:file:/C:/Users/as%20df/Documents/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib/ant.jar!/org/apache/tools/ant/Project.class
  </code></pre>
  
  <p>I've tried specifying each and every subdirectory, each and every class file, I've tried filesets and filelists, nothing seems to work.</p>
  
  <p>Thanks for your help, I've been sitting for hours on this thing now...</p>