org.apache.ant.antunit.listener
Class BaseAntUnitListener

java.lang.Object
  extended by 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
static class BaseAntUnitListener.AntUnitLogLevel
           
 class BaseAntUnitListener.LogGrabber
           
static class BaseAntUnitListener.SendLogTo
           
 
Field Summary
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 java.text.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.
 
Constructor Summary
protected BaseAntUnitListener(BaseAntUnitListener.SendLogTo defaultReportTarget, java.lang.String extension)
           
 
Method Summary
 void addError(java.lang.String target, java.lang.Throwable ae)
          Invoked if any error other than a failed assertion occured during execution.
 void addFailure(java.lang.String target, AssertionFailedException ae)
          Invoked if an assert tasked caused an error during execution.
protected  void close(java.io.OutputStream out)
           
protected  Project getCurrentTestProject()
           
protected  Location getLocation(java.lang.Throwable t)
           
protected  java.io.OutputStream getOut(java.lang.String buildFile)
           
protected  java.io.File getToDir()
          Directory to write reports to.
protected  void messageLogged(BuildEvent event)
          Gets messages from the project running the test target if their level is at least of the level specified with setLogLevel.
protected  java.lang.String normalize(java.lang.String buildFile)
          Turns the build file name into something that vaguely looks like a Java classname.
 void setCurrentTestProject(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(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(java.io.File f)
          Sets the directory to write test reports to.
 void startTest(java.lang.String target)
          Invoked before a test target gets executed.
 void startTestSuite(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.


setToDir

public void setToDir(java.io.File f)
Sets the directory to write test reports to.


setSendLogTo

protected void setSendLogTo(BaseAntUnitListener.SendLogTo logTo)
Where to send the test report.


setParentTask

public void setParentTask(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 interface AntUnitListener

startTestSuite

public void startTestSuite(Project testProject,
                           java.lang.String buildFile)
Description copied from interface: AntUnitListener
Invoked once per build file, before any targets get executed.

Specified by:
startTestSuite in interface AntUnitListener

close

protected final void close(java.io.OutputStream out)

startTest

public void startTest(java.lang.String target)
Description copied from interface: AntUnitListener
Invoked before a test target gets executed.

Specified by:
startTest in interface AntUnitListener

addFailure

public void addFailure(java.lang.String target,
                       AssertionFailedException ae)
Description copied from interface: AntUnitListener
Invoked if an assert tasked caused an error during execution.

Specified by:
addFailure in interface AntUnitListener

addError

public void addError(java.lang.String target,
                     java.lang.Throwable ae)
Description copied from interface: AntUnitListener
Invoked if any error other than a failed assertion occured during execution.

Specified by:
addError in interface AntUnitListener

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.


getLocation

protected final Location getLocation(java.lang.Throwable t)

setCurrentTestProject

public void setCurrentTestProject(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 interface AntUnitListener

getCurrentTestProject

protected 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.


messageLogged

protected void messageLogged(BuildEvent event)
Gets messages from the project running the test target if their level is at least of the level specified with setLogLevel.

This implementation is empty.