Class FailureRecorder

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.taskdefs.optional.junit.FailureRecorder
All Implemented Interfaces:
Cloneable, EventListener, junit.framework.TestListener, BuildListener, JUnitResultFormatter, JUnitTaskMirror.JUnitResultFormatterMirror

public class FailureRecorder extends ProjectComponent implements JUnitResultFormatter, BuildListener

Collects all failing test cases and creates a new JUnit test class containing a suite() method which calls these failed tests.

Having classes A ... D with each several testcases you could earn a new test class like

 // generated on: 2007.08.06 09:42:34,555
 import junit.framework.*;
 public class FailedTests extends TestCase {
     public FailedTests(String testname) {
         super(testname);
     }
     public static Test suite() {
         TestSuite suite = new TestSuite();
         suite.addTest(new B("test04"));
         suite.addTest(new org.D("test10"));
         return suite;
     }
 }
 
Because each running test case gets its own formatter, we collect the failing test cases in a static list. Because we don't have a finalizer method in the formatters "lifecycle", we register this formatter as BuildListener and generate the new java source on taskFinished event.
Since:
Ant 1.8.0