Class BriefJUnitResultFormatter

java.lang.Object
org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter
All Implemented Interfaces:
junit.framework.TestListener, IgnoredTestListener, JUnitResultFormatter, JUnitTaskMirror.JUnitResultFormatterMirror

public class BriefJUnitResultFormatter extends Object implements JUnitResultFormatter, IgnoredTestListener
Prints plain text output of the test to a specified Writer. Inspired by the PlainJUnitResultFormatter.
See Also:
  • Constructor Details

    • BriefJUnitResultFormatter

      public BriefJUnitResultFormatter()
      Constructor for BriefJUnitResultFormatter.
  • Method Details

    • setOutput

      public void setOutput(OutputStream out)
      Sets the stream the formatter is supposed to write its results to.
      Specified by:
      setOutput in interface JUnitResultFormatter
      Specified by:
      setOutput in interface JUnitTaskMirror.JUnitResultFormatterMirror
      Parameters:
      out - the output stream to write to
    • setSystemOutput

      public void setSystemOutput(String out)
      Description copied from interface: JUnitResultFormatter
      This is what the test has written to System.out
      Specified by:
      setSystemOutput in interface JUnitResultFormatter
      Parameters:
      out - the string to write.
      See Also:
    • setSystemError

      public void setSystemError(String err)
      Description copied from interface: JUnitResultFormatter
      This is what the test has written to System.err
      Specified by:
      setSystemError in interface JUnitResultFormatter
      Parameters:
      err - the string to write.
      See Also:
    • startTestSuite

      public void startTestSuite(JUnitTest suite)
      The whole testsuite started.
      Specified by:
      startTestSuite in interface JUnitResultFormatter
      Parameters:
      suite - the test suite
    • endTestSuite

      public void endTestSuite(JUnitTest suite)
      The whole testsuite ended.
      Specified by:
      endTestSuite in interface JUnitResultFormatter
      Parameters:
      suite - the test suite
    • startTest

      public void startTest(junit.framework.Test test)
      A test started.
      Specified by:
      startTest in interface junit.framework.TestListener
      Parameters:
      test - a test
    • endTest

      public void endTest(junit.framework.Test test)
      A test ended.
      Specified by:
      endTest in interface junit.framework.TestListener
      Parameters:
      test - a test
    • addFailure

      public void addFailure(junit.framework.Test test, Throwable t)
      Interface TestListener for JUnit <= 3.4.

      A Test failed.

      Parameters:
      test - a test
      t - the exception thrown by the test
    • addFailure

      public void addFailure(junit.framework.Test test, junit.framework.AssertionFailedError t)
      Interface TestListener for JUnit > 3.4.

      A Test failed.

      Specified by:
      addFailure in interface junit.framework.TestListener
      Parameters:
      test - a test
      t - the assertion failed by the test
    • addError

      public void addError(junit.framework.Test test, Throwable error)
      A test caused an error.
      Specified by:
      addError in interface junit.framework.TestListener
      Parameters:
      test - a test
      error - the error thrown by the test
    • formatTest

      protected String formatTest(junit.framework.Test test)
      Format the test for printing..
      Parameters:
      test - a test
      Returns:
      the formatted testname
    • formatError

      protected void formatError(String type, junit.framework.Test test, Throwable error)
      Format an error and print it.
      Parameters:
      type - the type of error
      test - the test that failed
      error - the exception that the test threw
    • testIgnored

      public void testIgnored(junit.framework.Test test)
      Description copied from interface: IgnoredTestListener
      Reports when a test has been marked with the @Ignore annotation. The parameter should normally be typed to JUnit's JUnit4TestCaseFacade so implementing classes should be able to get the details of the ignore by casting the argument and retrieving the descriptor from the test.
      Specified by:
      testIgnored in interface IgnoredTestListener
      Parameters:
      test - the details of the test and failure that have triggered this report.
    • formatSkip

      public void formatSkip(junit.framework.Test test, String message)
    • testAssumptionFailure

      public void testAssumptionFailure(junit.framework.Test test, Throwable cause)
      Description copied from interface: IgnoredTestListener
      Receive a report that a test has failed an assumption. Within JUnit4 this is normally treated as a test being skipped, although how any listener handles this is up to that specific listener.

      Note: Tests that throw assumption failures will still report the endTest method, which may differ from how the addError and addFailure methods work, it's up for any implementing classes to handle this.

      Specified by:
      testAssumptionFailure in interface IgnoredTestListener
      Parameters:
      test - the details of the test and failure that have triggered this report.
      cause - the AssumptionViolatedException thrown from the current assumption failure.