Class TextReport
- java.lang.Object
-
- com.carrotsearch.ant.tasks.junit4.listeners.TextReport
-
- All Implemented Interfaces:
AggregatedEventListener
public class TextReport extends java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TextReport.OutputMode
Display mode for output streams.
-
Field Summary
Fields Modifier and Type Field Description private boolean
append
Append tooutputFile
if specified.private static int
DEFAULT_MAX_LINE_WIDTH
Default 16kb for maximum line width buffer.private java.util.EnumMap<TestStatus,java.lang.Boolean>
displayStatus
Status display info.private WriterOutputStream
errStream
syserr recode stream.private PrefixedWriter
errWriter
Standard error, prefixed and decoded.private java.util.List<org.junit.runner.Description>
failedTests
A list of failed tests, if to be displayed at the end.private static java.lang.String
FAILURE_MARKER
Failure marker string.private static java.lang.String
FAILURE_STRING
private int
forkedJvmCount
Forked concurrent JVM count.private static java.lang.String
indent
private java.lang.String
jvmIdFormat
Format line for JVM ID string.private int
maxClassNameColumns
Maximum number of columns for class name.private java.io.Writer
output
AWriter
for writing output messages.private java.io.File
outputFile
output
file name.private TextReport.OutputMode
outputMode
private WriterOutputStream
outStream
sysout recode stream.private PrefixedWriter
outWriter
Standard output, prefixed and decoded.private java.lang.String
seed
private boolean
showEmptySuites
private int
showNumFailuresAtEnd
Summarize the first N failures at the end.private boolean
showStackTraces
private boolean
showSuiteSummary
private boolean
showThrowable
private java.util.List<StackTraceFilter>
stackFilters
Stack trace filters.private static java.util.EnumMap<TestStatus,java.lang.String>
statusNames
Status names column.private static java.lang.String
stderrIndent
private static java.lang.String
stdoutIndent
private java.util.concurrent.atomic.AtomicInteger
suitesCompleted
private boolean
timestamps
Display timestamps and durations for tests/ suites.private java.util.concurrent.atomic.AtomicInteger
totalErrors
private int
totalSuites
private static java.util.Set<java.lang.String>
UNICODE_ENCODINGS
Code pages which are capable of displaying all unicode glyphs.private boolean
useSimpleNames
Use simple names for suite names.
-
Constructor Summary
Constructors Constructor Description TextReport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConfigured(StackTraceFilter sfilter)
Filter stack traces from certain frames.private void
emitBufferedEvents(AggregatedSuiteResultEvent e)
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 java.lang.String
filterStackTrace(java.lang.String trace)
Filter stack trace ifaddConfigured(StackTraceFilter)
.private void
flushOutput()
Flush output streams.private boolean
isPassthrough()
private void
logShort(java.lang.CharSequence message)
logShort, trim whitespace.private void
logShort(java.lang.CharSequence message, boolean trim)
Log a message line to the output.void
onChildBootstrap(ChildBootstrap e)
void
onHeartbeat(HeartBeatEvent e)
void
onJvmOutput(JvmOutputEvent e)
void
onOutput(PartialOutputEvent e)
void
onQuit(AggregatedQuitEvent e)
void
onStart(AggregatedStartEvent e)
void
onSuiteResult(AggregatedSuiteResultEvent e)
void
onSuiteStart(AggregatedSuiteStartedEvent e)
void
onTestResult(AggregatedTestResultEvent e)
void
setAppend(boolean append)
Append ifsetFile(File)
is also specified.void
setFile(java.io.File outputFile)
Set an external file to write to.void
setMaxClassNameColumns(int maxClassNameColumns)
Set maximum number of class name columns before truncated with ellipsis.void
setOuter(JUnit4 task)
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(java.lang.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 java.lang.String
shortTimestamp(long ts)
Format a short timestamp.
-
-
-
Field Detail
-
indent
private static final java.lang.String indent
- See Also:
- Constant Field Values
-
stdoutIndent
private static final java.lang.String stdoutIndent
- See Also:
- Constant Field Values
-
stderrIndent
private static final java.lang.String stderrIndent
- See Also:
- Constant Field Values
-
FAILURE_MARKER
private static final java.lang.String FAILURE_MARKER
Failure marker string.- See Also:
- Constant Field Values
-
FAILURE_STRING
private static final java.lang.String FAILURE_STRING
- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
UNICODE_ENCODINGS
private static java.util.Set<java.lang.String> UNICODE_ENCODINGS
Code pages which are capable of displaying all unicode glyphs.
-
statusNames
private static java.util.EnumMap<TestStatus,java.lang.String> statusNames
Status names column.
-
showThrowable
private boolean showThrowable
- See Also:
setShowThrowable(boolean)
-
showStackTraces
private boolean showStackTraces
- See Also:
setShowStackTraces(boolean)
-
outputMode
private TextReport.OutputMode outputMode
- See Also:
setShowOutput(String)
-
showSuiteSummary
private boolean showSuiteSummary
- See Also:
setShowSuiteSummary(boolean)
-
showEmptySuites
private boolean showEmptySuites
- See Also:
#showEmptySuites(boolean)
-
displayStatus
private final java.util.EnumMap<TestStatus,java.lang.Boolean> displayStatus
Status display info.
-
output
private java.io.Writer output
AWriter
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 java.io.File outputFile
output
file name.
-
append
private boolean append
Append tooutputFile
if specified.
-
forkedJvmCount
private int forkedJvmCount
Forked concurrent JVM count.
-
jvmIdFormat
private java.lang.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 java.util.List<org.junit.runner.Description> failedTests
A list of failed tests, if to be displayed at the end.
-
stackFilters
private java.util.List<StackTraceFilter> stackFilters
Stack trace filters.
-
totalSuites
private int totalSuites
-
totalErrors
private java.util.concurrent.atomic.AtomicInteger totalErrors
-
suitesCompleted
private java.util.concurrent.atomic.AtomicInteger suitesCompleted
-
seed
private java.lang.String seed
-
-
Method Detail
-
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(boolean)
-
setShowStackTraces
public void setShowStackTraces(boolean showStackTraces)
Show stack trace information.
-
setShowOutput
public void setShowOutput(java.lang.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(java.io.File outputFile) throws java.io.IOException
Set an external file to write to. That file will always be in UTF-8.- Throws:
java.io.IOException
-
setAppend
public void setAppend(boolean append)
Append ifsetFile(File)
is also specified.
-
setOuter
public void setOuter(JUnit4 task)
Initialization by container taskJUnit4
.- Specified by:
setOuter
in interfaceAggregatedEventListener
-
onStart
public void onStart(AggregatedStartEvent e) throws java.io.IOException
- Throws:
java.io.IOException
-
onChildBootstrap
public void onChildBootstrap(ChildBootstrap e) throws java.io.IOException
- Throws:
java.io.IOException
-
onHeartbeat
public void onHeartbeat(HeartBeatEvent e) throws java.io.IOException
- Throws:
java.io.IOException
-
onQuit
public void onQuit(AggregatedQuitEvent e) throws java.io.IOException
- Throws:
java.io.IOException
-
onSuiteStart
public void onSuiteStart(AggregatedSuiteStartedEvent e) throws java.io.IOException
- Throws:
java.io.IOException
-
onOutput
public void onOutput(PartialOutputEvent e) throws java.io.IOException
- Throws:
java.io.IOException
-
onJvmOutput
public void onJvmOutput(JvmOutputEvent e) throws java.io.IOException
- Throws:
java.io.IOException
-
onTestResult
public void onTestResult(AggregatedTestResultEvent e) throws java.io.IOException
- Throws:
java.io.IOException
-
onSuiteResult
public void onSuiteResult(AggregatedSuiteResultEvent e) throws java.io.IOException
- Throws:
java.io.IOException
-
emitBufferedEvents
private void emitBufferedEvents(AggregatedSuiteResultEvent e) throws java.io.IOException
- Throws:
java.io.IOException
-
flushOutput
private void flushOutput() throws java.io.IOException
Flush output streams.- Throws:
java.io.IOException
-
emitSuiteStart
private void emitSuiteStart(org.junit.runner.Description description, long startTimestamp) throws java.io.IOException
Suite prologue.- Throws:
java.io.IOException
-
emitSuiteEnd
private void emitSuiteEnd(AggregatedSuiteResultEvent e, int suitesCompleted) throws java.io.IOException
Suite end.- Throws:
java.io.IOException
-
emitStatusLine
private void emitStatusLine(AggregatedResultEvent result, TestStatus status, long timeMillis) throws java.io.IOException
Emit status line for an aggregated event.- Throws:
java.io.IOException
-
filterStackTrace
private java.lang.String filterStackTrace(java.lang.String trace)
Filter stack trace ifaddConfigured(StackTraceFilter)
.
-
logShort
private void logShort(java.lang.CharSequence message, boolean trim) throws java.io.IOException
Log a message line to the output.- Throws:
java.io.IOException
-
logShort
private void logShort(java.lang.CharSequence message) throws java.io.IOException
logShort, trim whitespace.- Throws:
java.io.IOException
-
isPassthrough
private boolean isPassthrough()
- Returns:
true
if we can emit output directly and immediately.
-
shortTimestamp
private java.lang.String shortTimestamp(long ts)
Format a short timestamp.
-
-