Package org.apache.ant.antunit.listener
Class XMLAntUnitListener
- java.lang.Object
-
- org.apache.ant.antunit.listener.BaseAntUnitListener
-
- org.apache.ant.antunit.listener.XMLAntUnitListener
-
- All Implemented Interfaces:
AntUnitListener
public class XMLAntUnitListener extends BaseAntUnitListener
A test listener for <antunit> modelled after the XML JUnit test listener that is part of Ant.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.ant.antunit.listener.BaseAntUnitListener
BaseAntUnitListener.AntUnitLogLevel, BaseAntUnitListener.LogGrabber, BaseAntUnitListener.SendLogTo
-
-
Field Summary
Fields Modifier and Type Field Description private org.w3c.dom.ElementcurrentTestprivate org.w3c.dom.Documentdocprivate org.apache.tools.ant.util.DOMElementWriterdomWriprivate static java.lang.StringINDENTprivate java.lang.StringBufferlogCollects log messages.private java.io.OutputStreamoutprivate org.w3c.dom.Elementrootprivate java.io.Writerwri-
Fields inherited from class org.apache.ant.antunit.listener.BaseAntUnitListener
errorCount, failureCount, nf, runCount, start, testStart
-
-
Constructor Summary
Constructors Constructor Description XMLAntUnitListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddError(java.lang.String target, java.lang.Throwable ae)Invoked if any error other than a failed assertion occured during execution.voidaddFailure(java.lang.String target, AssertionFailedException ae)Invoked if an assert tasked caused an error during execution.voidendTest(java.lang.String target)Invoked after a test target has been executed.voidendTestSuite(org.apache.tools.ant.Project testProject, java.lang.String buildFile)Invoked once per build file, after all targets have been executed.private voidformatError(java.lang.String type, java.lang.Throwable t)private java.lang.StringgetHostname()get the local hostname - stolen from junit.XMLJUnitResultFormatterprotected voidmessageLogged(org.apache.tools.ant.BuildEvent event)Gets messages from the project running the test target if their level is at least of the level specified withsetLogLevel.voidstartTest(java.lang.String target)Invoked before a test target gets executed.voidstartTestSuite(org.apache.tools.ant.Project testProject, java.lang.String buildFile)Invoked once per build file, before any targets get executed.-
Methods inherited from class org.apache.ant.antunit.listener.BaseAntUnitListener
close, getCurrentTestProject, getLocation, getOut, getToDir, normalize, setCurrentTestProject, setLogLevel, setParentTask, setSendLogTo, setToDir
-
-
-
-
Field Detail
-
INDENT
private static final java.lang.String INDENT
- See Also:
- Constant Field Values
-
out
private java.io.OutputStream out
-
wri
private java.io.Writer wri
-
domWri
private org.apache.tools.ant.util.DOMElementWriter domWri
-
doc
private org.w3c.dom.Document doc
-
root
private org.w3c.dom.Element root
-
currentTest
private org.w3c.dom.Element currentTest
-
log
private java.lang.StringBuffer log
Collects log messages.
-
-
Method Detail
-
startTestSuite
public void startTestSuite(org.apache.tools.ant.Project testProject, java.lang.String buildFile)Description copied from interface:AntUnitListenerInvoked once per build file, before any targets get executed.- Specified by:
startTestSuitein interfaceAntUnitListener- Overrides:
startTestSuitein classBaseAntUnitListener- Parameters:
testProject- the projectbuildFile- the build file
-
endTestSuite
public void endTestSuite(org.apache.tools.ant.Project testProject, java.lang.String buildFile)Description copied from interface:AntUnitListenerInvoked once per build file, after all targets have been executed.- Parameters:
testProject- the projectbuildFile- the build file
-
startTest
public void startTest(java.lang.String target)
Description copied from interface:AntUnitListenerInvoked before a test target gets executed.- Specified by:
startTestin interfaceAntUnitListener- Overrides:
startTestin classBaseAntUnitListener- Parameters:
target- name of the target
-
endTest
public void endTest(java.lang.String target)
Description copied from interface:AntUnitListenerInvoked after a test target has been executed.- Parameters:
target- name of the target
-
addFailure
public void addFailure(java.lang.String target, AssertionFailedException ae)Description copied from interface:AntUnitListenerInvoked if an assert tasked caused an error during execution.- Specified by:
addFailurein interfaceAntUnitListener- Overrides:
addFailurein classBaseAntUnitListener- Parameters:
target- name of the targetae- the failure
-
addError
public void addError(java.lang.String target, java.lang.Throwable ae)Description copied from interface:AntUnitListenerInvoked if any error other than a failed assertion occured during execution.- Specified by:
addErrorin interfaceAntUnitListener- Overrides:
addErrorin classBaseAntUnitListener- Parameters:
target- name of the targetae- the error
-
formatError
private void formatError(java.lang.String type, java.lang.Throwable t)
-
messageLogged
protected void messageLogged(org.apache.tools.ant.BuildEvent event)
Description copied from class:BaseAntUnitListenerGets messages from the project running the test target if their level is at least of the level specified withsetLogLevel.This implementation is empty.
- Overrides:
messageLoggedin classBaseAntUnitListener- Parameters:
event- the logged message
-
getHostname
private java.lang.String getHostname()
get the local hostname - stolen from junit.XMLJUnitResultFormatter- Returns:
- the name of the local host, or "localhost" if we cannot work it out
-
-