public abstract class BaseAntUnitListener extends Object implements AntUnitListener
Modifier and Type | Class and Description |
---|---|
static class |
BaseAntUnitListener.AntUnitLogLevel |
class |
BaseAntUnitListener.LogGrabber |
static class |
BaseAntUnitListener.SendLogTo |
Modifier and Type | Field and Description |
---|---|
protected int |
errorCount
keeps track of the numer of executed targets, the failures an errors.
|
protected int |
failureCount
keeps track of the numer of executed targets, the failures an errors.
|
protected static NumberFormat |
nf
Formatter for timings.
|
protected int |
runCount
keeps track of the numer of executed targets, the failures an errors.
|
protected long |
start
time for the starts of the current test-suite and test-target.
|
protected long |
testStart
time for the starts of the current test-suite and test-target.
|
Modifier | Constructor and Description |
---|---|
protected |
BaseAntUnitListener(BaseAntUnitListener.SendLogTo defaultReportTarget,
String extension) |
Modifier and Type | Method and Description |
---|---|
void |
addError(String target,
Throwable ae)
Invoked if any error other than a failed assertion occured
during execution.
|
void |
addFailure(String target,
AssertionFailedException ae)
Invoked if an assert tasked caused an error during execution.
|
protected void |
close(OutputStream out) |
protected org.apache.tools.ant.Project |
getCurrentTestProject() |
protected org.apache.tools.ant.Location |
getLocation(Throwable t) |
protected OutputStream |
getOut(String buildFile) |
protected File |
getToDir()
Directory to write reports to.
|
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 with
setLogLevel . |
protected String |
normalize(String buildFile)
Turns the build file name into something that vaguely looks
like a Java classname.
|
void |
setCurrentTestProject(org.apache.tools.ant.Project p)
Set a reference to the Project instance currently executing the
test target.
|
void |
setLogLevel(BaseAntUnitListener.AntUnitLogLevel l)
Sets the minimum level a log message must be logged at to be
included in the output.
|
void |
setParentTask(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 void |
setSendLogTo(BaseAntUnitListener.SendLogTo logTo)
Where to send the test report.
|
void |
setToDir(File f)
Sets the directory to write test reports to.
|
void |
startTest(String target)
Invoked before a test target gets executed.
|
void |
startTestSuite(org.apache.tools.ant.Project testProject,
String buildFile)
Invoked once per build file, before any targets get executed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
endTest, endTestSuite
protected static final NumberFormat nf
protected int runCount
protected int failureCount
protected int errorCount
protected long start
protected long testStart
protected BaseAntUnitListener(BaseAntUnitListener.SendLogTo defaultReportTarget, String extension)
protected final File getToDir()
public void setToDir(File f)
f
- directory to write reports toprotected void setSendLogTo(BaseAntUnitListener.SendLogTo logTo)
logTo
- where to send the test reportpublic void setParentTask(org.apache.tools.ant.Task t)
AntUnitListener
setParentTask
in interface AntUnitListener
t
- the parent taskpublic void startTestSuite(org.apache.tools.ant.Project testProject, String buildFile)
AntUnitListener
startTestSuite
in interface AntUnitListener
testProject
- the projectbuildFile
- the build fileprotected final void close(OutputStream out)
public void startTest(String target)
AntUnitListener
startTest
in interface AntUnitListener
target
- name of the targetpublic void addFailure(String target, AssertionFailedException ae)
AntUnitListener
addFailure
in interface AntUnitListener
target
- name of the targetae
- the failurepublic void addError(String target, Throwable ae)
AntUnitListener
addError
in interface AntUnitListener
target
- name of the targetae
- the errorprotected final OutputStream getOut(String buildFile)
protected final String normalize(String buildFile)
buildFile
- the test file nameprotected final org.apache.tools.ant.Location getLocation(Throwable t)
public void setCurrentTestProject(org.apache.tools.ant.Project p)
AntUnitListener
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.
setCurrentTestProject
in interface AntUnitListener
p
- the test projectprotected org.apache.tools.ant.Project getCurrentTestProject()
public void setLogLevel(BaseAntUnitListener.AntUnitLogLevel l)
l
- minimum levelprotected void messageLogged(org.apache.tools.ant.BuildEvent event)
setLogLevel
.
This implementation is empty.
event
- the logged messageCopyright © 2023 The Apache Software Foundation. All rights reserved.