Package org.apache.ant.antunit.listener
Class BaseAntUnitListener
- java.lang.Object
-
- org.apache.ant.antunit.listener.BaseAntUnitListener
-
- All Implemented Interfaces:
AntUnitListener
- Direct Known Subclasses:
FailureAntUnitListener,PlainAntUnitListener,XMLAntUnitListener
public abstract class BaseAntUnitListener extends java.lang.Object implements AntUnitListener
A test listener for <antunit> modeled aftern the Plain JUnit test listener that is part of Ant.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBaseAntUnitListener.AntUnitLogLevelclassBaseAntUnitListener.LogGrabberstatic classBaseAntUnitListener.SendLogTo
-
Field Summary
Fields Modifier and Type Field Description protected interrorCountkeeps track of the numer of executed targets, the failures an errors.protected intfailureCountkeeps track of the numer of executed targets, the failures an errors.protected static java.text.NumberFormatnfFormatter for timings.protected intrunCountkeeps track of the numer of executed targets, the failures an errors.protected longstarttime for the starts of the current test-suite and test-target.protected longtestStarttime for the starts of the current test-suite and test-target.
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseAntUnitListener(BaseAntUnitListener.SendLogTo defaultReportTarget, java.lang.String extension)
-
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.protected voidclose(java.io.OutputStream out)protected org.apache.tools.ant.ProjectgetCurrentTestProject()protected org.apache.tools.ant.LocationgetLocation(java.lang.Throwable t)protected java.io.OutputStreamgetOut(java.lang.String buildFile)protected java.io.FilegetToDir()Directory to write reports to.protected 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.protected java.lang.Stringnormalize(java.lang.String buildFile)Turns the build file name into something that vaguely looks like a Java classname.voidsetCurrentTestProject(org.apache.tools.ant.Project p)Set a reference to the Project instance currently executing the test target.voidsetLogLevel(BaseAntUnitListener.AntUnitLogLevel l)Sets the minimum level a log message must be logged at to be included in the output.voidsetParentTask(org.apache.tools.ant.Task t)Set a reference to the AntUnit task executing the tests, this provides access to the containing project, target or Ant's logging system.protected voidsetSendLogTo(BaseAntUnitListener.SendLogTo logTo)Where to send the test report.voidsetToDir(java.io.File f)Sets the directory to write test reports to.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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.ant.antunit.AntUnitListener
endTest, endTestSuite
-
-
-
-
Field Detail
-
nf
protected static final java.text.NumberFormat nf
Formatter for timings.
-
runCount
protected int runCount
keeps track of the numer of executed targets, the failures an errors.
-
failureCount
protected int failureCount
keeps track of the numer of executed targets, the failures an errors.
-
errorCount
protected int errorCount
keeps track of the numer of executed targets, the failures an errors.
-
start
protected long start
time for the starts of the current test-suite and test-target.
-
testStart
protected long testStart
time for the starts of the current test-suite and test-target.
-
-
Constructor Detail
-
BaseAntUnitListener
protected BaseAntUnitListener(BaseAntUnitListener.SendLogTo defaultReportTarget, java.lang.String extension)
-
-
Method Detail
-
getToDir
protected final java.io.File getToDir()
Directory to write reports to.- Returns:
- directory to write reports to
-
setToDir
public void setToDir(java.io.File f)
Sets the directory to write test reports to.- Parameters:
f- directory to write reports to
-
setSendLogTo
protected void setSendLogTo(BaseAntUnitListener.SendLogTo logTo)
Where to send the test report.- Parameters:
logTo- where to send the test report
-
setParentTask
public void setParentTask(org.apache.tools.ant.Task t)
Description copied from interface:AntUnitListenerSet a reference to the AntUnit task executing the tests, this provides access to the containing project, target or Ant's logging system.- Specified by:
setParentTaskin interfaceAntUnitListener- Parameters:
t- the parent task
-
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- Parameters:
testProject- the projectbuildFile- the build file
-
close
protected final void close(java.io.OutputStream out)
-
startTest
public void startTest(java.lang.String target)
Description copied from interface:AntUnitListenerInvoked before a test target gets executed.- Specified by:
startTestin interfaceAntUnitListener- 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- 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- Parameters:
target- name of the targetae- the error
-
getOut
protected final java.io.OutputStream getOut(java.lang.String buildFile)
-
normalize
protected final java.lang.String normalize(java.lang.String buildFile)
Turns the build file name into something that vaguely looks like a Java classname. Close enough to be suitable for junitreport.- Parameters:
buildFile- the test file name- Returns:
- the normalized name
-
getLocation
protected final org.apache.tools.ant.Location getLocation(java.lang.Throwable t)
-
setCurrentTestProject
public void setCurrentTestProject(org.apache.tools.ant.Project p)
Description copied from interface:AntUnitListenerSet a reference to the Project instance currently executing the test target.This provides access to the logging system or the properties of the project under test. Note that different test targets will be executed in different Ant Project instances.
- Specified by:
setCurrentTestProjectin interfaceAntUnitListener- Parameters:
p- the test project
-
getCurrentTestProject
protected org.apache.tools.ant.Project getCurrentTestProject()
-
setLogLevel
public void setLogLevel(BaseAntUnitListener.AntUnitLogLevel l)
Sets the minimum level a log message must be logged at to be included in the output.- Parameters:
l- minimum level
-
messageLogged
protected void messageLogged(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.This implementation is empty.
- Parameters:
event- the logged message
-
-