java.lang.Object
com.carrotsearch.ant.tasks.junit4.listeners.TextReport
All Implemented Interfaces:
AggregatedEventListener

public class TextReport extends Object implements AggregatedEventListener
A listener that will subscribe to test execution and dump informational info about the progress to the console or a text file.
  • Field Details

    • indent

      private static final String indent
      See Also:
    • stdoutIndent

      private static final String stdoutIndent
      See Also:
    • stderrIndent

      private static final String stderrIndent
      See Also:
    • FAILURE_MARKER

      private static final String FAILURE_MARKER
      Failure marker string.
      See Also:
    • FAILURE_STRING

      private static final String FAILURE_STRING
      See Also:
    • DEFAULT_MAX_LINE_WIDTH

      private static final int DEFAULT_MAX_LINE_WIDTH
      Default 16kb for maximum line width buffer. Otherwise we may get OOMs buffering each line.
      See Also:
    • UNICODE_ENCODINGS

      private static Set<String> UNICODE_ENCODINGS
      Code pages which are capable of displaying all unicode glyphs.
    • statusNames

      private static EnumMap<TestStatus,String> statusNames
      Status names column.
    • showThrowable

      private boolean showThrowable
      See Also:
    • showStackTraces

      private boolean showStackTraces
      See Also:
    • outputMode

      private TextReport.OutputMode outputMode
      See Also:
    • showSuiteSummary

      private boolean showSuiteSummary
      See Also:
    • showEmptySuites

      private boolean showEmptySuites
      See Also:
      • invalid reference
        #showEmptySuites(boolean)
    • displayStatus

      private final EnumMap<TestStatus,Boolean> displayStatus
      Status display info.
    • output

      private Writer output
      A Writer for writing output messages.
    • maxClassNameColumns

      private int maxClassNameColumns
      Maximum number of columns for class name.
    • useSimpleNames

      private boolean useSimpleNames
      Use simple names for suite names.
    • timestamps

      private boolean timestamps
      Display timestamps and durations for tests/ suites.
    • outputFile

      private File outputFile
      output file name.
    • append

      private boolean append
      Append to outputFile if specified.
    • forkedJvmCount

      private int forkedJvmCount
      Forked concurrent JVM count.
    • jvmIdFormat

      private String jvmIdFormat
      Format line for JVM ID string.
    • outWriter

      private PrefixedWriter outWriter
      Standard output, prefixed and decoded.
    • errWriter

      private PrefixedWriter errWriter
      Standard error, prefixed and decoded.
    • outStream

      private WriterOutputStream outStream
      sysout recode stream.
    • errStream

      private WriterOutputStream errStream
      syserr recode stream.
    • showNumFailuresAtEnd

      private int showNumFailuresAtEnd
      Summarize the first N failures at the end.
    • failedTests

      private List<org.junit.runner.Description> failedTests
      A list of failed tests, if to be displayed at the end.
    • stackFilters

      private List<StackTraceFilter> stackFilters
      Stack trace filters.
    • totalSuites

      private int totalSuites
    • totalErrors

      private AtomicInteger totalErrors
    • suitesCompleted

      private AtomicInteger suitesCompleted
    • seed

      private String seed
  • Constructor Details

    • TextReport

      public TextReport()
  • Method Details

    • setShowStatusError

      public void setShowStatusError(boolean showStatus)
    • setShowStatusFailure

      public void setShowStatusFailure(boolean showStatus)
    • setShowStatusOk

      public void setShowStatusOk(boolean showStatus)
    • setShowStatusIgnored

      public void setShowStatusIgnored(boolean showStatus)
    • setMaxClassNameColumns

      public void setMaxClassNameColumns(int maxClassNameColumns)
      Set maximum number of class name columns before truncated with ellipsis.
    • setUseSimpleNames

      public void setUseSimpleNames(boolean useSimpleNames)
      Use simple class names for suite naming.
    • setTimestamps

      public void setTimestamps(boolean timestamps)
      Show duration timestamps for tests and suites.
    • addConfigured

      public void addConfigured(StackTraceFilter sfilter)
      Filter stack traces from certain frames.
    • setShowThrowable

      public void setShowThrowable(boolean showThrowable)
      If enabled, displays extended error information for tests that failed (exception class, message, stack trace, standard streams).
      See Also:
    • setShowStackTraces

      public void setShowStackTraces(boolean showStackTraces)
      Show stack trace information.
    • setShowOutput

      public void setShowOutput(String mode)
      Display mode for output streams.
    • setShowNumFailures

      public void setShowNumFailures(int num)
      Summarize N failures at the end of the report.
    • setShowEmptySuites

      public void setShowEmptySuites(boolean showEmptySuites)
      Display suites without any errors and with no tests (resulting from filtering expressions, for example).
    • setShowSuiteSummary

      public void setShowSuiteSummary(boolean showSuiteSummary)
      If enabled, shows suite summaries in "maven-like" format of:
       Running SuiteName
       [...suite tests if enabled...]
       Tests: xx, Failures: xx, Errors: xx, Skipped: xx, Time: xx sec [<<< FAILURES!]
       
    • setFile

      public void setFile(File outputFile) throws IOException
      Set an external file to write to. That file will always be in UTF-8.
      Throws:
      IOException
    • setAppend

      public void setAppend(boolean append)
      Append if setFile(File) is also specified.
    • setOuter

      public void setOuter(JUnit4 task)
      Initialization by container task JUnit4.
      Specified by:
      setOuter in interface AggregatedEventListener
    • onStart

      public void onStart(AggregatedStartEvent e) throws IOException
      Throws:
      IOException
    • onChildBootstrap

      public void onChildBootstrap(ChildBootstrap e) throws IOException
      Throws:
      IOException
    • onHeartbeat

      public void onHeartbeat(HeartBeatEvent e) throws IOException
      Throws:
      IOException
    • onQuit

      public void onQuit(AggregatedQuitEvent e) throws IOException
      Throws:
      IOException
    • onSuiteStart

      public void onSuiteStart(AggregatedSuiteStartedEvent e) throws IOException
      Throws:
      IOException
    • onOutput

      public void onOutput(PartialOutputEvent e) throws IOException
      Throws:
      IOException
    • onJvmOutput

      public void onJvmOutput(JvmOutputEvent e) throws IOException
      Throws:
      IOException
    • onTestResult

      public void onTestResult(AggregatedTestResultEvent e) throws IOException
      Throws:
      IOException
    • onSuiteResult

      public void onSuiteResult(AggregatedSuiteResultEvent e) throws IOException
      Throws:
      IOException
    • emitBufferedEvents

      private void emitBufferedEvents(AggregatedSuiteResultEvent e) throws IOException
      Throws:
      IOException
    • flushOutput

      private void flushOutput() throws IOException
      Flush output streams.
      Throws:
      IOException
    • emitSuiteStart

      private void emitSuiteStart(org.junit.runner.Description description, long startTimestamp) throws IOException
      Suite prologue.
      Throws:
      IOException
    • emitSuiteEnd

      private void emitSuiteEnd(AggregatedSuiteResultEvent e, int suitesCompleted) throws IOException
      Suite end.
      Throws:
      IOException
    • emitStatusLine

      private void emitStatusLine(AggregatedResultEvent result, TestStatus status, long timeMillis) throws IOException
      Emit status line for an aggregated event.
      Throws:
      IOException
    • filterStackTrace

      private String filterStackTrace(String trace)
      Filter stack trace if addConfigured(StackTraceFilter).
    • logShort

      private void logShort(CharSequence message, boolean trim) throws IOException
      Log a message line to the output.
      Throws:
      IOException
    • logShort

      private void logShort(CharSequence message) throws IOException
      logShort, trim whitespace.
      Throws:
      IOException
    • isPassthrough

      private boolean isPassthrough()
      Returns:
      true if we can emit output directly and immediately.
    • shortTimestamp

      private String shortTimestamp(long ts)
      Format a short timestamp.