Class ReportPrinter
All index parameters are 0-based internally. Public methods printDetails(java.lang.String, java.util.Map<java.lang.String, rife.bld.extension.junitreporter.TestClassFailures>)
and hasIndex(java.lang.String, java.util.Map<java.lang.String, rife.bld.extension.junitreporter.TestClassFailures>) accept 1-based indices from CLI input.
Index format: N for group N, or N.M for failure M in group N.
Example: 1.2 refers to the 2nd failure in the 1st test class.
Important: Index assignment depends on iteration order of the provided map.
Callers must pass a LinkedHashMap or TreeMap
to guarantee stable indexes across runs. Passing a HashMap will
cause --index=N to refer to different classes unpredictably.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Method Summary
Modifier and TypeMethodDescriptionstatic TestClassFailuresgetFailuresByIndex(Map<String, TestClassFailures> groupedFailures, int index) Returns theTestClassFailuresat the given 0-based index.static booleanChecks whether the given index string refers to a valid test or failure.static StringIndents each line of the input text by 8 spaces.static StringIndents each line of the input text by the specified number of spaces.static voidprintDetails(String arg, Map<String, TestClassFailures> groupedFailures) Prints the details of test failures based on 1-based CLI argument.static voidprintFailure(TestFailure failure, @Nullable Integer groupIndex, @Nullable Integer failureIndex) Prints details of a single test failure with optional indices.static voidprintFailures(TestClassFailures failures, int groupIndex) Prints all failures for a test class using 0-based group index.static voidprintFailureWithStackTrace(TestFailure failure, int groupIndex, int failureIndex) Prints failure details with header and stack trace using 0-based indices.static voidprintHeader(String title) Prints a header with the specified title.static voidprintStackTrace(TestFailure failure) Prints the stack trace of the provided test failure, if available.static voidprintSummary(Map<String, TestClassFailures> groupedFailures) Prints a summary of JUnit test failures grouped by test class.
-
Method Details
-
getFailuresByIndex
public static TestClassFailures getFailuresByIndex(Map<String, TestClassFailures> groupedFailures, int index) Returns theTestClassFailuresat the given 0-based index.Assumes
groupedFailuresiteration order is stable. UseLinkedHashMaporTreeMapto guarantee consistent index assignment across runs.- Parameters:
groupedFailures- a map of test class failuresindex- the 0-based index- Returns:
- the
TestClassFailuresat the specified index - Throws:
NullPointerException- if the map isnullIllegalArgumentException- if the map is emptyIndexOutOfBoundsException- if the index is out of bounds
-
hasIndex
public static boolean hasIndex(@Nullable String arg, @Nullable Map<String, TestClassFailures> groupedFailures) Checks whether the given index string refers to a valid test or failure.Accepts
groupIndexorgroupIndex.failureIndexin 1-based form.- Parameters:
arg- a string representing 1-based indices, e.g. "1" or "1.2"groupedFailures- a map of test class failures- Returns:
trueif the index is valid,falseotherwise
-
indent
Indents each line of the input text by the specified number of spaces. Blank lines are not indented.- Parameters:
text- the input text; may be null or emptyindentSize- the number of spaces to indent each line- Returns:
- the indented text, or empty string if input is null/empty
- Throws:
IllegalArgumentException- ifindentSizeis negative
-
indent
Indents each line of the input text by 8 spaces.- Parameters:
text- the input text- Returns:
- the indented text with each line prefixed by 8 spaces
-
printDetails
Prints the details of test failures based on 1-based CLI argument.Accepts
groupIndexorgroupIndex.failureIndex. Converts 1-based input to 0-based internally.- Parameters:
arg- a string representing 1-based indices, e.g. "1" or "1.2"groupedFailures- a map of test class failures- Throws:
IllegalArgumentException- if the index format is invalidIndexOutOfBoundsException- if the specified indices are out of boundsNumberFormatException- if the numeric portion cannot be parsed
-
printFailure
public static void printFailure(TestFailure failure, @Nullable Integer groupIndex, @Nullable Integer failureIndex) Prints details of a single test failure with optional indices.- Parameters:
failure- theTestFailureto printgroupIndex- the 0-based group index, ornullfailureIndex- the 0-based failure index, ornull
-
printFailureWithStackTrace
public static void printFailureWithStackTrace(TestFailure failure, int groupIndex, int failureIndex) Prints failure details with header and stack trace using 0-based indices.- Parameters:
failure- theTestFailureto printgroupIndex- the 0-based group indexfailureIndex- the 0-based failure index
-
printFailures
Prints all failures for a test class using 0-based group index.- Parameters:
failures- theTestClassFailuresto printgroupIndex- the 0-based group index
-
printHeader
Prints a header with the specified title.- Parameters:
title- the title to print
-
printStackTrace
Prints the stack trace of the provided test failure, if available.- Parameters:
failure- theTestFailurecontaining the stack trace
-
printSummary
Prints a summary of JUnit test failures grouped by test class.- Parameters:
groupedFailures- a map of test class failures
-