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 classTextReport.OutputModeDisplay mode for output streams.
-
Field Summary
Fields Modifier and Type Field Description private booleanappendAppend tooutputFileif specified.private static intDEFAULT_MAX_LINE_WIDTHDefault 16kb for maximum line width buffer.private java.util.EnumMap<TestStatus,java.lang.Boolean>displayStatusStatus display info.private WriterOutputStreamerrStreamsyserr recode stream.private PrefixedWritererrWriterStandard error, prefixed and decoded.private java.util.List<org.junit.runner.Description>failedTestsA list of failed tests, if to be displayed at the end.private static java.lang.StringFAILURE_MARKERFailure marker string.private static java.lang.StringFAILURE_STRINGprivate intforkedJvmCountForked concurrent JVM count.private static java.lang.Stringindentprivate java.lang.StringjvmIdFormatFormat line for JVM ID string.private intmaxClassNameColumnsMaximum number of columns for class name.private java.io.WriteroutputAWriterfor writing output messages.private java.io.FileoutputFileoutputfile name.private TextReport.OutputModeoutputModeprivate WriterOutputStreamoutStreamsysout recode stream.private PrefixedWriteroutWriterStandard output, prefixed and decoded.private java.lang.Stringseedprivate booleanshowEmptySuitesprivate intshowNumFailuresAtEndSummarize the first N failures at the end.private booleanshowStackTracesprivate booleanshowSuiteSummaryprivate booleanshowThrowableprivate java.util.List<StackTraceFilter>stackFiltersStack trace filters.private static java.util.EnumMap<TestStatus,java.lang.String>statusNamesStatus names column.private static java.lang.StringstderrIndentprivate static java.lang.StringstdoutIndentprivate java.util.concurrent.atomic.AtomicIntegersuitesCompletedprivate booleantimestampsDisplay timestamps and durations for tests/ suites.private java.util.concurrent.atomic.AtomicIntegertotalErrorsprivate inttotalSuitesprivate static java.util.Set<java.lang.String>UNICODE_ENCODINGSCode pages which are capable of displaying all unicode glyphs.private booleanuseSimpleNamesUse simple names for suite names.
-
Constructor Summary
Constructors Constructor Description TextReport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConfigured(StackTraceFilter sfilter)Filter stack traces from certain frames.private voidemitBufferedEvents(AggregatedSuiteResultEvent e)private 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 java.lang.StringfilterStackTrace(java.lang.String trace)Filter stack trace ifaddConfigured(StackTraceFilter).private voidflushOutput()Flush output streams.private booleanisPassthrough()private voidlogShort(java.lang.CharSequence message)logShort, trim whitespace.private voidlogShort(java.lang.CharSequence message, boolean trim)Log a message line to the output.voidonChildBootstrap(ChildBootstrap e)voidonHeartbeat(HeartBeatEvent e)voidonJvmOutput(JvmOutputEvent e)voidonOutput(PartialOutputEvent e)voidonQuit(AggregatedQuitEvent e)voidonStart(AggregatedStartEvent e)voidonSuiteResult(AggregatedSuiteResultEvent e)voidonSuiteStart(AggregatedSuiteStartedEvent e)voidonTestResult(AggregatedTestResultEvent e)voidsetAppend(boolean append)Append ifsetFile(File)is also specified.voidsetFile(java.io.File outputFile)Set an external file to write to.voidsetMaxClassNameColumns(int maxClassNameColumns)Set maximum number of class name columns before truncated with ellipsis.voidsetOuter(JUnit4 task)Initialization 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(java.lang.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 java.lang.StringshortTimestamp(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
AWriterfor 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
outputfile name.
-
append
private boolean append
Append tooutputFileif 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.IOExceptionSet 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:
setOuterin 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.IOExceptionFlush output streams.- Throws:
java.io.IOException
-
emitSuiteStart
private void emitSuiteStart(org.junit.runner.Description description, long startTimestamp) throws java.io.IOExceptionSuite 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.IOExceptionLog a message line to the output.- Throws:
java.io.IOException
-
logShort
private void logShort(java.lang.CharSequence message) throws java.io.IOExceptionlogShort, trim whitespace.- Throws:
java.io.IOException
-
isPassthrough
private boolean isPassthrough()
- Returns:
trueif we can emit output directly and immediately.
-
shortTimestamp
private java.lang.String shortTimestamp(long ts)
Format a short timestamp.
-
-