Package rife.bld.extension.junitreporter
Class ReportPrinter
java.lang.Object
rife.bld.extension.junitreporter.ReportPrinter
Utility class for printing detailed and structured reports of test failures.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Method Summary
Modifier and TypeMethodDescriptionstatic TestClassFailures
getFailuresByGroupIndex
(Map<String, TestClassFailures> groupedFailures, int index) Retrieves the test class failures associated with a specific group index from the provided map.static String
Indents each line of the input text by 8 spaces (default indentation).static String
Indents each line of the input text by the specified number of spaces.static void
printDetails
(String arg, Map<String, TestClassFailures> groupedFailures) Prints the details of test failures based on the given argument and grouped failures.static void
printFailure
(TestFailure failure, Integer groupIndex, Integer failureIndex) Prints details of a single test failure, including optional group and failure indices.static void
printFailures
(TestClassFailures failures, int groupIndex) Prints the failures of a specific test class along with their group and failure indices.static void
printFailureWithStackTrace
(TestFailure failure, int groupIndex, int failureIndex) Prints the failure details, including its formatted group and failure indices, and displays the associated stack trace.static void
printHeader
(String title) Prints a header with the specified title.static void
printStackTrace
(TestFailure failure) Prints the stack trace of the provided test failure, if available.static void
printSummary
(Map<String, TestClassFailures> groupedFailures) Prints a summary of JUnit test failures grouped by test class.
-
Method Details
-
getFailuresByGroupIndex
public static TestClassFailures getFailuresByGroupIndex(Map<String, TestClassFailures> groupedFailures, int index) throws IndexOutOfBoundsException, IllegalArgumentExceptionRetrieves the test class failures associated with a specific group index from the provided map.- Parameters:
groupedFailures
- a map where the key is a string representing the group name, and the value is aTestClassFailures
object representing the failures for that groupindex
- the index of the group whose failures are to be retrieved- Returns:
- the
TestClassFailures
object associated with the specified group index - Throws:
IllegalArgumentException
- if the map isnull
or emptyIndexOutOfBoundsException
- if the index is out of range
-
indent
Indents each line of the input text by the specified number of spaces.- Parameters:
text
- The input text containing one or more linesindentSize
- The number of spaces to indent each line- Returns:
- The indented text with each line prefixed by the specified number of spaces
- Throws:
IllegalArgumentException
-
indent
Indents each line of the input text by 8 spaces (default indentation).- Parameters:
text
- The input text containing one or more lines- Returns:
- The indented text with each line prefixed by 8 spaces
-
printDetails
public static void printDetails(String arg, Map<String, TestClassFailures> groupedFailures) throws NumberFormatException, IndexOutOfBoundsExceptionPrints the details of test failures based on the given argument and grouped failures.- Parameters:
arg
- a string representing the group index or group and failure indices in the formatgroupIndex
orgroupIndex.failureIndex
groupedFailures
- a map where the key is a string representing the group name, and the value is aTestClassFailures
object containing the failures for that group- Throws:
NumberFormatException
- if the numeric portion of the argument cannot be parsedIndexOutOfBoundsException
- if the specified indices are out of bounds
-
printFailure
Prints details of a single test failure, including optional group and failure indices.- Parameters:
failure
- TheTestFailure
object that encapsulates the details of the test failuregroupIndex
- The index of the group this failure belongs to, ornull
if not applicablefailureIndex
- The index of the failure within the group, ornull
if not applicable
-
printFailureWithStackTrace
public static void printFailureWithStackTrace(TestFailure failure, int groupIndex, int failureIndex) Prints the failure details, including its formatted group and failure indices, and displays the associated stack trace.- Parameters:
failure
- TheTestFailure
object representing the test failure detailsgroupIndex
- The index of the group this failure belongs tofailureIndex
- The index of the failure within the group
-
printFailures
Prints the failures of a specific test class along with their group and failure indices.- Parameters:
failures
- theTestClassFailures
object containing the test failures associated with a specific test classgroupIndex
- the index of the group to which the test class belongs
-
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
- TheTestFailure
object containing the details and stack trace of the test failure to be printed
-
printSummary
Prints a summary of JUnit test failures grouped by test class.- Parameters:
groupedFailures
- a map where the key is a string representing the group name, and the value is aTestClassFailures
object that contains the failures for that group
-