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
A test listener for <antunit> modeled aftern the Plain JUnit
test listener that is part of Ant.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.tools.ant.Project
protected int
keeps track of the numer of executed targets, the failures an errors.private String
Extension for report files.protected int
keeps track of the numer of executed targets, the failures an errors.The minimum level a log message must be logged at to be included in the output.private BaseAntUnitListener.SendLogTo
Where to send log.protected static final NumberFormat
Formatter for timings.private org.apache.tools.ant.Task
protected int
keeps track of the numer of executed targets, the failures an errors.protected long
time for the starts of the current test-suite and test-target.protected long
time for the starts of the current test-suite and test-target.private File
Directory to write reports to. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseAntUnitListener
(BaseAntUnitListener.SendLogTo defaultReportTarget, String extension) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 final void
close
(OutputStream out) protected org.apache.tools.ant.Project
protected final org.apache.tools.ant.Location
protected final OutputStream
protected final 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 withsetLogLevel
.protected final String
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
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
Where to send the test report.void
Sets the directory to write test reports to.void
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.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 Details
-
nf
Formatter for timings. -
toDir
Directory to write reports to. -
extension
Extension for report files. -
logTo
Where to send log. -
parentTask
private org.apache.tools.ant.Task parentTask -
runCount
protected int runCountkeeps track of the numer of executed targets, the failures an errors. -
failureCount
protected int failureCountkeeps track of the numer of executed targets, the failures an errors. -
errorCount
protected int errorCountkeeps track of the numer of executed targets, the failures an errors. -
start
protected long starttime for the starts of the current test-suite and test-target. -
testStart
protected long testStarttime for the starts of the current test-suite and test-target. -
currentTest
private org.apache.tools.ant.Project currentTest -
logLevel
The minimum level a log message must be logged at to be included in the output.
-
-
Constructor Details
-
BaseAntUnitListener
-
-
Method Details
-
getToDir
Directory to write reports to.- Returns:
- directory to write reports to
-
setToDir
Sets the directory to write test reports to.- Parameters:
f
- directory to write reports to
-
setSendLogTo
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:AntUnitListener
Set a reference to the AntUnit task executing the tests, this provides access to the containing project, target or Ant's logging system.- Specified by:
setParentTask
in interfaceAntUnitListener
- Parameters:
t
- the parent task
-
startTestSuite
Description copied from interface:AntUnitListener
Invoked once per build file, before any targets get executed.- Specified by:
startTestSuite
in interfaceAntUnitListener
- Parameters:
testProject
- the projectbuildFile
- the build file
-
close
-
startTest
Description copied from interface:AntUnitListener
Invoked before a test target gets executed.- Specified by:
startTest
in interfaceAntUnitListener
- Parameters:
target
- name of the target
-
addFailure
Description copied from interface:AntUnitListener
Invoked if an assert tasked caused an error during execution.- Specified by:
addFailure
in interfaceAntUnitListener
- Parameters:
target
- name of the targetae
- the failure
-
addError
Description copied from interface:AntUnitListener
Invoked if any error other than a failed assertion occured during execution.- Specified by:
addError
in interfaceAntUnitListener
- Parameters:
target
- name of the targetae
- the error
-
getOut
-
normalize
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
-
setCurrentTestProject
public void setCurrentTestProject(org.apache.tools.ant.Project p) Description copied from interface:AntUnitListener
Set 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:
setCurrentTestProject
in interfaceAntUnitListener
- Parameters:
p
- the test project
-
getCurrentTestProject
protected org.apache.tools.ant.Project getCurrentTestProject() -
setLogLevel
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
-