title: Running Junit through Ant does not seem to use custom class runner
body: <p>I have a custom runner that ships Junit tests over a socket connection to a Junit server running on other hardware. The tests run as intended with the following target:</p>
  
  <pre><code>    &lt;target name="run"&gt;
          &lt;mkdir dir="reports" /&gt;
          &lt;junit fork="yes" haltonfailure="no"&gt;
              &lt;test name="${CurrentTest}" /&gt;
              &lt;formatter type="xml" /&gt;
              &lt;classpath refid="mastersuite.classpath" /&gt;
          &lt;/junit&gt;
  
          &lt;junitreport todir="${JunitReport.dir}"&gt;
              &lt;fileset dir="."&gt;
                  &lt;include name="TEST-*.xml" /&gt;           
              &lt;/fileset&gt;
              &lt;report todir="${JunitReport.dir}" /&gt;
          &lt;/junitreport&gt;
      &lt;/target&gt;
  </code></pre>
  
  <p>However, when I add in the following &lt;batchtest&gt; element...</p>
  
  <pre><code>&lt;target name="run"&gt;
      &lt;delete dir="reports" failonerror="false" /&gt;        
      &lt;!-- Make the reports directory --&gt;
      &lt;mkdir dir="reports" /&gt;
  
      &lt;!-- Execute the tests and saves the results to XML --&gt;
      &lt;junit fork="yes" printsummary="no" haltonfailure="no"&gt;
          &lt;batchtest fork="yes" todir="${JunitReport.dir}"&gt;
              &lt;fileset dir="${APITesting.classes}"&gt;
                  &lt;include name="test/api/**/*Test.class" /&gt;
              &lt;/fileset&gt;
          &lt;/batchtest&gt;
          &lt;formatter type="xml" /&gt;
          &lt;classpath refid="mastersuite.classpath" /&gt;
      &lt;/junit&gt;
  
      &lt;!-- Compile the resulting XML file into an HTML based report. --&gt;
      &lt;junitreport todir="${JunitReport.dir}"&gt;
          &lt;fileset dir="${JunitReport.dir}"&gt;
              &lt;include name="TEST-*.xml" /&gt;
          &lt;/fileset&gt;
          &lt;report todir="${JunitReport.dir}" /&gt;
      &lt;/junitreport&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>nothing gets shipped over to the hardware, which leads me to believe that my @RunWith(com.company.name.RemoteTestCaseRunner.class) annotation is not being honored within the context of &lt;batchtest&gt;. Is there something I am forgetting to do, or perhaps that must be done additionally for my @RunWith annotation to be called?</p>
  
  <p>The tests are still being run and the reports are created, and certain tests that are not platform dependent do run and pass, just not the ones that require communication with services on the target hardware.</p>
  
  <p><strong>UPDATE</strong> I have determined that this works fine when using @RunWith(Suite.class) paired with @SuiteClasses({}), just not if I explicitly give it a test case. So now I'm really not sure where the problem lies.</p>
  
  <p><strong>UPDATE</strong> While I haven't found anything solid on this, the behavior of my tests seem to imply the following: based on the way my tests are formatted (they extend TestCase) I think Ant is executing my test cases as Junit3 tests. As stated above, when I run a test suite formatted for Junit4 (using only annotations) my tests run and are executed as intended. It seems that when I pass the Junit3 formatted test case directly is when my annotations are not honored, which implies that the Junit3 runner is being used.</p>
  
  <p>My new question is this: is there a way to explicitly tell ant to use the Junit 4 runner?</p>