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 classclassstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.tools.ant.Projectprotected intkeeps track of the numer of executed targets, the failures an errors.private StringExtension for report files.protected intkeeps 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.SendLogToWhere to send log.protected static final NumberFormatFormatter for timings.private org.apache.tools.ant.Taskprotected intkeeps track of the numer of executed targets, the failures an errors.protected longtime for the starts of the current test-suite and test-target.protected longtime for the starts of the current test-suite and test-target.private FileDirectory to write reports to. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseAntUnitListener(BaseAntUnitListener.SendLogTo defaultReportTarget, String extension) -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked if any error other than a failed assertion occured during execution.voidaddFailure(String target, AssertionFailedException ae) Invoked if an assert tasked caused an error during execution.protected final voidclose(OutputStream out) protected org.apache.tools.ant.Projectprotected final org.apache.tools.ant.Locationprotected final OutputStreamprotected final 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 final StringTurns 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.voidSets 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 voidWhere to send the test report.voidSets the directory to write test reports to.voidInvoked before a test target gets executed.voidstartTestSuite(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, waitMethods 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: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
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
-
startTest
Description copied from interface:AntUnitListenerInvoked before a test target gets executed.- Specified by:
startTestin interfaceAntUnitListener- Parameters:
target- name of the target
-
addFailure
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
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
-
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: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
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
-