Class TextReport
java.lang.Object
com.carrotsearch.ant.tasks.junit4.listeners.TextReport
- All Implemented Interfaces:
AggregatedEventListener
A listener that will subscribe to test execution and dump
informational info about the progress to the console or a text
file.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDisplay mode for output streams. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanAppend tooutputFileif specified.private static final intDefault 16kb for maximum line width buffer.private final EnumMap<TestStatus, Boolean> Status display info.private WriterOutputStreamsyserr recode stream.private PrefixedWriterStandard error, prefixed and decoded.private List<org.junit.runner.Description> A list of failed tests, if to be displayed at the end.private static final StringFailure marker string.private static final Stringprivate intForked concurrent JVM count.private static final Stringprivate StringFormat line for JVM ID string.private intMaximum number of columns for class name.private WriterAWriterfor writing output messages.private Fileoutputfile name.private TextReport.OutputModeprivate WriterOutputStreamsysout recode stream.private PrefixedWriterStandard output, prefixed and decoded.private Stringprivate booleanprivate intSummarize the first N failures at the end.private booleanprivate booleanprivate booleanprivate List<StackTraceFilter> Stack trace filters.private static EnumMap<TestStatus, String> Status names column.private static final Stringprivate static final Stringprivate AtomicIntegerprivate booleanDisplay timestamps and durations for tests/ suites.private AtomicIntegerprivate intCode pages which are capable of displaying all unicode glyphs.private booleanUse simple names for suite names. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConfigured(StackTraceFilter sfilter) Filter stack traces from certain frames.private voidprivate voidemitStatusLine(AggregatedResultEvent result, TestStatus status, long timeMillis) Emit status line for an aggregated event.private voidemitSuiteEnd(AggregatedSuiteResultEvent e, int suitesCompleted) Suite end.private voidemitSuiteStart(org.junit.runner.Description description, long startTimestamp) Suite prologue.private StringfilterStackTrace(String trace) Filter stack trace ifaddConfigured(StackTraceFilter).private voidFlush output streams.private booleanprivate voidlogShort(CharSequence message) logShort, trim whitespace.private voidlogShort(CharSequence message, boolean trim) Log a message line to the output.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidsetAppend(boolean append) Append ifsetFile(File)is also specified.voidSet an external file to write to.voidsetMaxClassNameColumns(int maxClassNameColumns) Set maximum number of class name columns before truncated with ellipsis.voidInitialization by container taskJUnit4.voidsetShowEmptySuites(boolean showEmptySuites) Display suites without any errors and with no tests (resulting from filtering expressions, for example).voidsetShowNumFailures(int num) Summarize N failures at the end of the report.voidsetShowOutput(String mode) Display mode for output streams.voidsetShowStackTraces(boolean showStackTraces) Show stack trace information.voidsetShowStatusError(boolean showStatus) voidsetShowStatusFailure(boolean showStatus) voidsetShowStatusIgnored(boolean showStatus) voidsetShowStatusOk(boolean showStatus) voidsetShowSuiteSummary(boolean showSuiteSummary) If enabled, shows suite summaries in "maven-like" format of:voidsetShowThrowable(boolean showThrowable) If enabled, displays extended error information for tests that failed (exception class, message, stack trace, standard streams).voidsetTimestamps(boolean timestamps) Show duration timestamps for tests and suites.voidsetUseSimpleNames(boolean useSimpleNames) Use simple class names for suite naming.private StringshortTimestamp(long ts) Format a short timestamp.
-
Field Details
-
indent
- See Also:
-
stdoutIndent
- See Also:
-
stderrIndent
- See Also:
-
FAILURE_MARKER
-
FAILURE_STRING
- See Also:
-
DEFAULT_MAX_LINE_WIDTH
private static final int DEFAULT_MAX_LINE_WIDTHDefault 16kb for maximum line width buffer. Otherwise we may get OOMs buffering each line.- See Also:
-
UNICODE_ENCODINGS
-
statusNames
Status names column. -
showThrowable
private boolean showThrowable- See Also:
-
showStackTraces
private boolean showStackTraces- See Also:
-
outputMode
- See Also:
-
showSuiteSummary
private boolean showSuiteSummary- See Also:
-
showEmptySuites
private boolean showEmptySuites- See Also:
-
displayStatus
Status display info. -
output
-
maxClassNameColumns
private int maxClassNameColumnsMaximum number of columns for class name. -
useSimpleNames
private boolean useSimpleNamesUse simple names for suite names. -
timestamps
private boolean timestampsDisplay timestamps and durations for tests/ suites. -
outputFile
-
append
private boolean appendAppend tooutputFileif specified. -
forkedJvmCount
private int forkedJvmCountForked concurrent JVM count. -
jvmIdFormat
Format line for JVM ID string. -
outWriter
Standard output, prefixed and decoded. -
errWriter
Standard error, prefixed and decoded. -
outStream
sysout recode stream. -
errStream
syserr recode stream. -
showNumFailuresAtEnd
private int showNumFailuresAtEndSummarize the first N failures at the end. -
failedTests
A list of failed tests, if to be displayed at the end. -
stackFilters
Stack trace filters. -
totalSuites
private int totalSuites -
totalErrors
-
suitesCompleted
-
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
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
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
Set an external file to write to. That file will always be in UTF-8.- Throws:
IOException
-
setAppend
public void setAppend(boolean append) Append ifsetFile(File)is also specified. -
setOuter
Initialization by container taskJUnit4.- Specified by:
setOuterin interfaceAggregatedEventListener
-
onStart
- Throws:
IOException
-
onChildBootstrap
- Throws:
IOException
-
onHeartbeat
- Throws:
IOException
-
onQuit
- Throws:
IOException
-
onSuiteStart
- Throws:
IOException
-
onOutput
- Throws:
IOException
-
onJvmOutput
- Throws:
IOException
-
onTestResult
- Throws:
IOException
-
onSuiteResult
- Throws:
IOException
-
emitBufferedEvents
- Throws:
IOException
-
flushOutput
-
emitSuiteStart
private void emitSuiteStart(org.junit.runner.Description description, long startTimestamp) throws IOException Suite prologue.- Throws:
IOException
-
emitSuiteEnd
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
Filter stack trace ifaddConfigured(StackTraceFilter). -
logShort
Log a message line to the output.- Throws:
IOException
-
logShort
logShort, trim whitespace.- Throws:
IOException
-
isPassthrough
private boolean isPassthrough()- Returns:
trueif we can emit output directly and immediately.
-
shortTimestamp
Format a short timestamp.
-