Class DefaultReporterFactory
- java.lang.Object
-
- org.apache.maven.plugin.surefire.report.DefaultReporterFactory
-
- All Implemented Interfaces:
ReporterFactory
public class DefaultReporterFactory extends java.lang.Object implements ReporterFactory
Provides reporting modules on the plugin side.
Keeps a centralized count of test run results.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DefaultReporterFactory.TestResultType
-
Field Summary
Fields Modifier and Type Field Description private ConsoleLogger
consoleLogger
private java.util.Map<java.lang.String,java.util.List<TestMethodStats>>
errorTests
private java.util.Map<java.lang.String,java.util.List<TestMethodStats>>
failedTests
private java.util.Map<java.lang.String,java.util.List<TestMethodStats>>
flakyTests
private RunStatistics
globalStats
private java.util.Collection<TestSetRunListener>
listeners
private StartupReportConfiguration
reportConfiguration
-
Constructor Summary
Constructors Constructor Description DefaultReporterFactory(StartupReportConfiguration reportConfiguration, ConsoleLogger consoleLogger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addListener(TestSetRunListener listener)
RunResult
close()
Closes the factory, freeing resources allocated in the factory.private TestcycleConsoleOutputReceiver
createConsoleOutputReceiver()
private ConsoleReporter
createConsoleReporter()
private FileReporter
createFileReporter()
RunListener
createReporter()
Creates a reporter.private StatelessXmlReporter
createSimpleXMLReporter()
private StatisticsReporter
createStatisticsReporter()
private void
err(java.lang.String s)
private void
failure(java.lang.String s)
RunStatistics
getGlobalRunStatistics()
java.io.File
getReportsDirectory()
(package private) static DefaultReporterFactory.TestResultType
getTestResultType(java.util.List<ReportEntryType> reportEntries, int rerunFailingTestsCount)
Get the result of a test based on all its runs.private void
info(java.lang.String s)
private void
log(java.lang.String s)
private void
log(java.lang.String s, boolean success, boolean failures, boolean errors, boolean skipped, boolean flakes)
private void
log(java.lang.String s, Level level)
void
mergeFromOtherFactories(java.util.Collection<DefaultReporterFactory> factories)
(package private) void
mergeTestHistoryResult()
Merge all the TestMethodStats in each TestRunListeners and put results into flakyTests, failedTests and errorTests, indexed by test class and method name.(package private) boolean
printTestFailures(DefaultReporterFactory.TestResultType type)
Print failed tests and flaked tests.private void
runCompleted()
void
runStarting()
private boolean
shouldReportToConsole()
private void
success(java.lang.String s)
-
-
-
Field Detail
-
reportConfiguration
private final StartupReportConfiguration reportConfiguration
-
consoleLogger
private final ConsoleLogger consoleLogger
-
listeners
private final java.util.Collection<TestSetRunListener> listeners
-
globalStats
private RunStatistics globalStats
-
flakyTests
private java.util.Map<java.lang.String,java.util.List<TestMethodStats>> flakyTests
-
failedTests
private java.util.Map<java.lang.String,java.util.List<TestMethodStats>> failedTests
-
errorTests
private java.util.Map<java.lang.String,java.util.List<TestMethodStats>> errorTests
-
-
Constructor Detail
-
DefaultReporterFactory
public DefaultReporterFactory(StartupReportConfiguration reportConfiguration, ConsoleLogger consoleLogger)
-
-
Method Detail
-
createReporter
public RunListener createReporter()
Description copied from interface:ReporterFactory
Creates a reporter.- Specified by:
createReporter
in interfaceReporterFactory
- Returns:
- A reporter instance
-
getReportsDirectory
public java.io.File getReportsDirectory()
-
createConsoleReporter
private ConsoleReporter createConsoleReporter()
-
createFileReporter
private FileReporter createFileReporter()
-
createSimpleXMLReporter
private StatelessXmlReporter createSimpleXMLReporter()
-
createConsoleOutputReceiver
private TestcycleConsoleOutputReceiver createConsoleOutputReceiver()
-
createStatisticsReporter
private StatisticsReporter createStatisticsReporter()
-
shouldReportToConsole
private boolean shouldReportToConsole()
-
mergeFromOtherFactories
public void mergeFromOtherFactories(java.util.Collection<DefaultReporterFactory> factories)
-
addListener
final void addListener(TestSetRunListener listener)
-
close
public RunResult close()
Description copied from interface:ReporterFactory
Closes the factory, freeing resources allocated in the factory.- Specified by:
close
in interfaceReporterFactory
- Returns:
- The run result
-
runStarting
public void runStarting()
-
runCompleted
private void runCompleted()
-
getGlobalRunStatistics
public RunStatistics getGlobalRunStatistics()
-
getTestResultType
static DefaultReporterFactory.TestResultType getTestResultType(java.util.List<ReportEntryType> reportEntries, int rerunFailingTestsCount)
Get the result of a test based on all its runs. If it has success and failures/errors, then it is a flake; if it only has errors or failures, then count its result based on its first run- Parameters:
reportEntries
- the list of test run report type for a given testrerunFailingTestsCount
- configured rerun count for failing tests- Returns:
- the type of test result
-
mergeTestHistoryResult
void mergeTestHistoryResult()
Merge all the TestMethodStats in each TestRunListeners and put results into flakyTests, failedTests and errorTests, indexed by test class and method name. Update globalStatistics based on the result of the merge.
-
printTestFailures
boolean printTestFailures(DefaultReporterFactory.TestResultType type)
Print failed tests and flaked tests. A test is considered as a failed test if it failed/got an error with all the runs. If a test passes in ever of the reruns, it will be count as a flaked test- Parameters:
type
- the type of results to be printed, could be error, failure or flake- Returns:
true
if printed some lines
-
log
private void log(java.lang.String s, boolean success, boolean failures, boolean errors, boolean skipped, boolean flakes)
-
log
private void log(java.lang.String s, Level level)
-
log
private void log(java.lang.String s)
-
info
private void info(java.lang.String s)
-
err
private void err(java.lang.String s)
-
success
private void success(java.lang.String s)
-
failure
private void failure(java.lang.String s)
-
-