org.apache.tools.ant.taskdefs.optional.junit
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 dont 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
| Nested Class Summary | |
|---|---|
| static class | FailureRecorder.TestInfos
TestInfos holds information about a given test for later use. |
| Field Summary | |
|---|---|
| static String | DEFAULT_CLASS_LOCATION Default location and name for the generated JUnit class file,
in the temp directory + FailedTests |
| static String | MAGIC_PROPERTY_CLASS_LOCATION
This is the name of a magic System property ({@value }). |
| Method Summary | |
|---|---|
| void | addError(Test test, Throwable throwable)
Add the failed test to the list. |
| void | addFailure(Test test, AssertionFailedError error)
Add the failed test to the list. |
| void | buildFinished(BuildEvent event)
Not used
|
| void | buildStarted(BuildEvent event)
Not used
|
| void | endTest(Test test)
Not used
|
| void | endTestSuite(JUnitTest suite)
Not used
|
| void | log(String message)
Logging facade in INFO-mode. |
| void | messageLogged(BuildEvent event)
Not used
|
| void | setOutput(OutputStream out)
Not used
|
| void | setProject(Project project)
This method is called by the Ant runtime by reflection. |
| void | setSystemError(String err)
Not used
|
| void | setSystemOutput(String out)
Not used
|
| void | startTest(Test test)
Not used
|
| void | startTestSuite(JUnitTest suite)
Not used
|
| void | targetFinished(BuildEvent event)
Not used
|
| void | targetStarted(BuildEvent event)
Not used
|
| void | taskFinished(BuildEvent event)
The task outside of this JUnitResultFormatter is the |
| void | taskStarted(BuildEvent event)
Not used
|
| void | verbose(String message)
Logging facade in VERBOSE-mode. |
See Also: DEFAULT_CLASS_LOCATION
Parameters: test the test that errored. throwable the reason it errored.
See Also: junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable)
Parameters: test the test that failed. error the assertion that failed.
See Also: junit.framework.TestListener#addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
Parameters: message Log-message
Parameters: project project reference
Parameters: event not used
See Also: taskFinished
Parameters: message Log-message