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 TestClassFailuresgetFailuresByGroupIndex(Map<String, TestClassFailures> groupedFailures, int index) Retrieves the test class failures associated with a specific group index from the provided map.static StringIndents each line of the input text by 8 spaces (default indentation).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 the given argument and grouped failures.static voidprintFailure(TestFailure failure, Integer groupIndex, Integer failureIndex) Prints details of a single test failure, including optional group and failure indices.static voidprintFailures(TestClassFailures failures, int groupIndex) Prints the failures of a specific test class along with their group and failure indices.static voidprintFailureWithStackTrace(TestFailure failure, int groupIndex, int failureIndex) Prints the failure details, including its formatted group and failure indices, and displays the associated stack trace.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
-
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 aTestClassFailuresobject representing the failures for that groupindex- the index of the group whose failures are to be retrieved- Returns:
- the
TestClassFailuresobject associated with the specified group index - Throws:
IllegalArgumentException- if the map isnullor 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 formatgroupIndexorgroupIndex.failureIndexgroupedFailures- a map where the key is a string representing the group name, and the value is aTestClassFailuresobject 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- TheTestFailureobject that encapsulates the details of the test failuregroupIndex- The index of the group this failure belongs to, ornullif not applicablefailureIndex- The index of the failure within the group, ornullif 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- TheTestFailureobject 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- theTestClassFailuresobject 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- TheTestFailureobject 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 aTestClassFailuresobject that contains the failures for that group
-