title: Ant - Setting ClassPath Does Not Work For Batch Test
body: <p>I have this and works fine:</p>
  
  <pre><code>&lt;target name="runjunit"&gt;
      &lt;junit&gt;
          &lt;classpath&gt;
              &lt;pathelement path="${build}"/&gt;
              &lt;fileset dir="lib"&gt;
                  &lt;include name="*.jar"/&gt;
              &lt;/fileset&gt;
          &lt;/classpath&gt; 
          &lt;test name="com.xyzcompany.abcproject.test.junit.CalculatorTest"/&gt;
          &lt;formatter type="brief" usefile="false"/&gt;
      &lt;/junit&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>However, I have multiple tests. So I do this:</p>
  
  <pre><code>&lt;target name="runjunit"&gt;
      &lt;junit&gt;
          &lt;classpath&gt;
              &lt;pathelement path="${build}"/&gt; &lt;---- this doesn't seem to work anymore
              &lt;fileset dir="lib"&gt;
                  &lt;include name="*.jar"/&gt;
              &lt;/fileset&gt;
          &lt;/classpath&gt; 
          &lt;batchtest&gt;
              &lt;fileset dir="com/xyzcompany/abcproject/test/junit"&gt;
                  &lt;include name="**/*.*"/&gt;
              &lt;/fileset&gt;
          &lt;/batchtest&gt;
          &lt;formatter type="brief" usefile="false"/&gt;
      &lt;/junit&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>However, that tells me the directory doesn't exist:</p>
  
  <p><code>C:\Users\me\Desktop\repository\mainproj\trunk\com\xyzcompany\abcproject\test\junit does not exist.</code></p>
  
  <p>The above should be:</p>
  
  <p><code>C:\Users\me\Desktop\repository\mainproj\trunk\build\com\xyzcompany\abcproject\test\junit</code></p>
  
  <p>As you see, the pathelement in classpath would set trunk/build/com in the single test, but doesn't in batchtest.</p>
  
  <p>Directory and package names obfuscated for privacy.</p>
  
  <p>Any idea how I can change the batchtest so pathelement in classpath actually works? Thanks!</p>
  
  <p>EDIT:</p>
  
  <p>This doesn't work:</p>
  
  <pre><code>&lt;batchtest&gt;
      &lt;fileset dir="${build}/com/xyzcompany/abcproject/test/junit"&gt;
          &lt;include name="**/*.*" /&gt;
      &lt;/fileset&gt;
  &lt;/batchtest&gt;
  </code></pre>
  
  <p>It gives me:</p>
  
  <p><code>java.lang.ClassNotFoundException: CalculatorTest</code></p>
  
  <p>Setting it to <code>&lt;fileset dir="${build}/com/xyzcompany/abcproject/test/junit"&gt;</code> doesn't make any sense since the class doesn't know it is under build. Thus, setting the classpath is the correct option, but doesn't work for <code>&lt;batchtest&gt;</code>.</p>
  
  <p>EDIT 2:</p>
  
  <p>Now that I really think about it, it does make sense to do <code>&lt;fileset dir="${build}/com/xyzcompany/abcproject/test/junit"&gt;</code>. However, when it spins up <code>java</code> for <code>junit</code> it doesn't run junit from the <code>${build}</code> classpath.</p>
  
  <p>EDIT 3:</p>
  
  <pre><code>&lt;batchtest&gt;
      &lt;fileset dir="${build}"&gt;
          &lt;include name="com/xyzcopmany/abcproject/test/junit/*"/&gt;
      &lt;/fileset&gt;
  &lt;/batchtest&gt;
  </code></pre>
  
  <p>Final answers. Ant should really have better documentation. It is a complex product...</p>