Class FailureAntUnitListener

java.lang.Object
org.apache.ant.antunit.listener.BaseAntUnitListener
org.apache.ant.antunit.listener.FailureAntUnitListener
All Implemented Interfaces:
AntUnitListener

public class FailureAntUnitListener extends BaseAntUnitListener
This AntUnitListener creates a new buildfile with a target for each failed test target in the AntUnit run. The generated target calls the failed target (with setUp and tearDown if present in the called project). This is intended for rerunning just failed tests.
  • Field Details

    • BR

      private static final String BR
      LineSeparator just for beautifying the output.
    • failedTests

      private static SortedSet failedTests
      A sorted list (without duplicates) of failed tests.
    • failureBuildfile

      private static File failureBuildfile
      Where to write the generated buildfile.
    • currentTestProject

      private org.apache.tools.ant.Project currentTestProject
      The current running test project. Needed for addError()/addFailure().
    • currentBuildFile

      private String currentBuildFile
      The current running build file. Needed for addError()/addFailure().
  • Constructor Details

    • FailureAntUnitListener

      public FailureAntUnitListener()
      No-arg constructor.
  • Method Details

    • setFile

      public void setFile(File file)
    • 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
      Overrides:
      startTestSuite in class BaseAntUnitListener
      Parameters:
      testProject - the project
      buildFile - the build file
    • 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
      Overrides:
      addError in class BaseAntUnitListener
      Parameters:
      target - name of the target
      ae - the error
    • 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
      Overrides:
      addFailure in class BaseAntUnitListener
      Parameters:
      target - name of the target
      ae - the failure
    • endTest

      public void endTest(String target)
      not in use
      Parameters:
      target - name of the target
    • endTestSuite

      public void endTestSuite(org.apache.tools.ant.Project testProject, String buildFile)
      Description copied from interface: AntUnitListener
      Invoked once per build file, after all targets have been executed.
      Parameters:
      testProject - the project
      buildFile - the build file