org.fest.swing.junit.ant
Class XmlJUnitResultFormatter

java.lang.Object
  extended by org.fest.swing.junit.ant.XmlJUnitResultFormatter
All Implemented Interfaces:
junit.framework.TestListener, org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter, org.apache.tools.ant.taskdefs.optional.junit.JUnitTaskMirror.JUnitResultFormatterMirror
Direct Known Subclasses:
ScreenshotOnFailureResultFormatter

public class XmlJUnitResultFormatter
extends Object
implements org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter

Understands a copy of the original XMLJUnitResultFormatter, with flexibility for extension.

Author:
Alex Ruiz

Constructor Summary
XmlJUnitResultFormatter()
          Creates a new XmlJUnitResultFormatter.
 
Method Summary
 void addError(junit.framework.Test test, Throwable error)
          An error occurred while running the test.
 void addFailure(junit.framework.Test test, junit.framework.AssertionFailedError failedAssertion)
          A test failed.
 void addFailure(junit.framework.Test test, Throwable error)
          A test failed.
 void endTest(junit.framework.Test test)
          A test is finished.
 void endTestSuite(org.apache.tools.ant.taskdefs.optional.junit.JUnitTest suite)
          The whole test suite ended.
protected  void onFailureOrError(junit.framework.Test test, Throwable error, XmlNode errorXmlNode)
          Hook for subclasses to add extra functionality after a test failure or a test execution error.
protected  void onStartTestSuite(org.apache.tools.ant.taskdefs.optional.junit.JUnitTest suite)
          Hook for subclasses to add extra functionality after the whole test suite started.
 void setOutput(OutputStream out)
          Sets the stream the formatter is supposed to write its results to.
 void setSystemError(String out)
          This is what the test has written to System.err.
 void setSystemOutput(String out)
          This is what the test has written to System.out,
 void startTest(junit.framework.Test test)
          A new test is started.
 void startTestSuite(org.apache.tools.ant.taskdefs.optional.junit.JUnitTest suite)
          The whole test suite started.
protected  void writeErrorAndStackTrace(Throwable error, XmlNode errorXmlNode)
          Writes the stack trace and message of the given error to the given XML node.
protected  XmlNode xmlRootNode()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlJUnitResultFormatter

public XmlJUnitResultFormatter()
Creates a new XmlJUnitResultFormatter.

Method Detail

setOutput

public final void setOutput(OutputStream out)
Sets the stream the formatter is supposed to write its results to.

Specified by:
setOutput in interface org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
Specified by:
setOutput in interface org.apache.tools.ant.taskdefs.optional.junit.JUnitTaskMirror.JUnitResultFormatterMirror
Parameters:
out - the output stream to use.

setSystemOutput

public final void setSystemOutput(String out)
This is what the test has written to System.out,

Specified by:
setSystemOutput in interface org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
Parameters:
out - the String to write.

setSystemError

public final void setSystemError(String out)
This is what the test has written to System.err.

Specified by:
setSystemError in interface org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
Parameters:
out - the String to write.

xmlRootNode

protected final XmlNode xmlRootNode()

startTestSuite

public final void startTestSuite(org.apache.tools.ant.taskdefs.optional.junit.JUnitTest suite)
The whole test suite started. This method starts creation of the XML report.

Specified by:
startTestSuite in interface org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
Parameters:
suite - the test suite.
Throws:
ExceptionInInitializerError - if the underlying XML document could not be created.

onStartTestSuite

protected void onStartTestSuite(org.apache.tools.ant.taskdefs.optional.junit.JUnitTest suite)
Hook for subclasses to add extra functionality after the whole test suite started.

Parameters:
suite - the test suite.

endTestSuite

public final void endTestSuite(org.apache.tools.ant.taskdefs.optional.junit.JUnitTest suite)
The whole test suite ended. This method finishes writing the XML report and writes its contents to this formatter's OutputStream.

Specified by:
endTestSuite in interface org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
Parameters:
suite - the test suite.
Throws:
org.apache.tools.ant.BuildException - on error.

startTest

public final void startTest(junit.framework.Test test)
A new test is started.

Specified by:
startTest in interface junit.framework.TestListener
Parameters:
test - the test.

endTest

public final void endTest(junit.framework.Test test)
A test is finished.

Specified by:
endTest in interface junit.framework.TestListener
Parameters:
test - the test.

addFailure

public final void addFailure(junit.framework.Test test,
                             junit.framework.AssertionFailedError failedAssertion)
A test failed.

Specified by:
addFailure in interface junit.framework.TestListener
Parameters:
test - the test.
failedAssertion - the failed assertion.

addFailure

public final void addFailure(junit.framework.Test test,
                             Throwable error)
A test failed.

Parameters:
test - the test.
error - the exception.

addError

public final void addError(junit.framework.Test test,
                           Throwable error)
An error occurred while running the test.

Specified by:
addError in interface junit.framework.TestListener
Parameters:
test - the test.
error - the error.

writeErrorAndStackTrace

protected final void writeErrorAndStackTrace(Throwable error,
                                             XmlNode errorXmlNode)
Writes the stack trace and message of the given error to the given XML node.

Parameters:
error - the given error.
errorXmlNode - the XML node to write to.

onFailureOrError

protected void onFailureOrError(junit.framework.Test test,
                                Throwable error,
                                XmlNode errorXmlNode)
Hook for subclasses to add extra functionality after a test failure or a test execution error.

Parameters:
test - the executing test.
error - the reason of the failure or error.
errorXmlNode - the XML element containing information about the test failure or error.


Copyright © 2007-2010 FEST (Fixtures for Easy Software Testing). All Rights Reserved.