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 Object implements AntUnitListener
A test listener for <antunit> modeled aftern the Plain JUnit test listener that is part of Ant.
  • Field Details

    • nf

      protected static final NumberFormat nf
      Formatter for timings.
    • toDir

      private File toDir
      Directory to write reports to.
    • extension

      private String extension
      Extension for report files.
    • logTo

      Where to send log.
    • parentTask

      private org.apache.tools.ant.Task parentTask
    • 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.
    • 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

  • Method Details

    • getToDir

      protected final File getToDir()
      Directory to write reports to.
      Returns:
      directory to write reports to
    • setToDir

      public void setToDir(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: 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
      Parameters:
      t - the parent task
    • startTestSuite

      public void startTestSuite(org.apache.tools.ant.Project testProject, String buildFile)
      Description copied from interface: AntUnitListener
      Invoked once per build file, before any targets get executed.
      Specified by:
      startTestSuite in interface AntUnitListener
      Parameters:
      testProject - the project
      buildFile - the build file
    • close

      protected final void close(OutputStream out)
    • startTest

      public void startTest(String target)
      Description copied from interface: AntUnitListener
      Invoked before a test target gets executed.
      Specified by:
      startTest in interface AntUnitListener
      Parameters:
      target - name of the target
    • addFailure

      public void addFailure(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
      Parameters:
      target - name of the target
      ae - the failure
    • addError

      public void addError(String target, 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
      Parameters:
      target - name of the target
      ae - the error
    • getOut

      protected final OutputStream getOut(String buildFile)
    • normalize

      protected final String normalize(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(Throwable t)
    • 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 interface AntUnitListener
      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 with setLogLevel.

      This implementation is empty.

      Parameters:
      event - the logged message