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 enum
Display mode for output streams. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Append tooutputFile
if specified.private static final int
Default 16kb for maximum line width buffer.private final EnumMap
<TestStatus, Boolean> Status display info.private WriterOutputStream
syserr recode stream.private PrefixedWriter
Standard 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 String
Failure marker string.private static final String
private int
Forked concurrent JVM count.private static final String
private String
Format line for JVM ID string.private int
Maximum number of columns for class name.private Writer
AWriter
for writing output messages.private File
output
file name.private TextReport.OutputMode
private WriterOutputStream
sysout recode stream.private PrefixedWriter
Standard output, prefixed and decoded.private String
private boolean
private int
Summarize the first N failures at the end.private boolean
private boolean
private boolean
private List
<StackTraceFilter> Stack trace filters.private static EnumMap
<TestStatus, String> Status names column.private static final String
private static final String
private AtomicInteger
private boolean
Display timestamps and durations for tests/ suites.private AtomicInteger
private int
Code pages which are capable of displaying all unicode glyphs.private boolean
Use simple names for suite names. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfigured
(StackTraceFilter sfilter) Filter stack traces from certain frames.private void
private void
emitStatusLine
(AggregatedResultEvent result, TestStatus status, long timeMillis) Emit status line for an aggregated event.private void
emitSuiteEnd
(AggregatedSuiteResultEvent e, int suitesCompleted) Suite end.private void
emitSuiteStart
(org.junit.runner.Description description, long startTimestamp) Suite prologue.private String
filterStackTrace
(String trace) Filter stack trace ifaddConfigured(StackTraceFilter)
.private void
Flush output streams.private boolean
private void
logShort
(CharSequence message) logShort, trim whitespace.private void
logShort
(CharSequence message, boolean trim) Log a message line to the output.void
void
void
void
void
void
void
void
void
void
setAppend
(boolean append) Append ifsetFile(File)
is also specified.void
Set an external file to write to.void
setMaxClassNameColumns
(int maxClassNameColumns) Set maximum number of class name columns before truncated with ellipsis.void
Initialization by container taskJUnit4
.void
setShowEmptySuites
(boolean showEmptySuites) Display suites without any errors and with no tests (resulting from filtering expressions, for example).void
setShowNumFailures
(int num) Summarize N failures at the end of the report.void
setShowOutput
(String mode) Display mode for output streams.void
setShowStackTraces
(boolean showStackTraces) Show stack trace information.void
setShowStatusError
(boolean showStatus) void
setShowStatusFailure
(boolean showStatus) void
setShowStatusIgnored
(boolean showStatus) void
setShowStatusOk
(boolean showStatus) void
setShowSuiteSummary
(boolean showSuiteSummary) If enabled, shows suite summaries in "maven-like" format of:void
setShowThrowable
(boolean showThrowable) If enabled, displays extended error information for tests that failed (exception class, message, stack trace, standard streams).void
setTimestamps
(boolean timestamps) Show duration timestamps for tests and suites.void
setUseSimpleNames
(boolean useSimpleNames) Use simple class names for suite naming.private String
shortTimestamp
(long ts) Format a short timestamp.
-
Field Details
-
indent
- See Also:
-
stdoutIndent
- See Also:
-
stderrIndent
- See Also:
-
FAILURE_MARKER
Failure marker string.- See Also:
-
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
Code pages which are capable of displaying all unicode glyphs. -
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
AWriter
for writing output messages. -
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
output
file name. -
append
private boolean appendAppend tooutputFile
if 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:
setOuter
in 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
Flush output streams.- Throws:
IOException
-
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:
true
if we can emit output directly and immediately.
-
shortTimestamp
Format a short timestamp.
-