title: Generating reports for junit when test methods run individually
body: <p>I have a Java project with JUnit tests which I run on Jenkins using Ant. Following various tutorials online, I made it possible for all the tests to run individually.</p>
  
  <p>My <strong>build.xml</strong> looks like this:</p>
  
  <pre><code>&lt;target name="run_junit" depends="compile, ensure-test-name"
                                    description="Run JUnit tests"&gt;
      &lt;echo message="Execute Test" /&gt;
      &lt;junit printsummary="withOutAndErr" fork="yes"&gt;
          &lt;sysproperty key="tests" value="${tests}"/&gt;
          &lt;classpath&gt;
              &lt;path refid="classpath"/&gt;
              &lt;pathelement path="bin"/&gt;
          &lt;/classpath&gt;
        &lt;formatter type="xml"/&gt;
        &lt;batchtest&gt;
           &lt;fileset dir="src"&gt;
               &lt;include name="${test}.java"/&gt;
           &lt;/fileset&gt;
        &lt;/batchtest&gt;
      &lt;/junit&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>This, together with my own Runner and Filter classes, and <code>@RunWith</code> annotations, means that I can run an individual test within an individual class like this:</p>
  
  <pre><code>ant run_junit -Dtest=ClassWithTests -Dtests=testMethod
  </code></pre>
  
  <p>This works perfectly fine, in Jenkins as well, and I am also able to run the tests in parallel. The problem I have is that the reports for each class get overwritten after each method is run.</p>
  
  <p>For example, the above command will produce a file <strong>TEST-ClassWithTests.xml</strong> with information about the result and output of <em>testMethod</em>. However, if I then run</p>
  
  <pre><code>ant run_junit -Dtest=ClassWithTests -Dtests=anotherTestMethod
  </code></pre>
  
  <p>the <strong>TEST-ClassWithTests.xml</strong> file will get overwritten and will only contain information about the result and output of <em>anotherTestMethod</em>.</p>
  
  <hr>
  
  <hr>
  
  <p>So my question is: How do I make JUnit generate separate test reports for each method? And is there some way of nicely combining them so that they display well on Jenkins? I would ask whether it is possible to append methods to an existing JUnit report, but these tests are meant to be running in parallel, so that would probably not be helpful.</p>