Class ReportPrinter

java.lang.Object
rife.bld.extension.junitreporter.ReportPrinter

public final class ReportPrinter extends Object
Utility class for printing detailed and structured reports of test failures.
Since:
1.0
Author:
Erik C. Thauvin
  • Method Details

    • getFailuresByGroupIndex

      public static TestClassFailures getFailuresByGroupIndex(Map<String,TestClassFailures> groupedFailures, int index) throws IndexOutOfBoundsException, IllegalArgumentException
      Retrieves 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 a TestClassFailures object representing the failures for that group
      index - 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 is null or empty
      IndexOutOfBoundsException - if the index is out of range
    • indent

      public static String indent(String text, int indentSize) throws IllegalArgumentException
      Indents each line of the input text by the specified number of spaces.
      Parameters:
      text - The input text containing one or more lines
      indentSize - 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

      public static String indent(String text)
      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, IndexOutOfBoundsException
      Prints 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 format groupIndex or groupIndex.failureIndex
      groupedFailures - a map where the key is a string representing the group name, and the value is a TestClassFailures object containing the failures for that group
      Throws:
      NumberFormatException - if the numeric portion of the argument cannot be parsed
      IndexOutOfBoundsException - if the specified indices are out of bounds
    • printFailure

      public static void printFailure(TestFailure failure, Integer groupIndex, Integer failureIndex)
      Prints details of a single test failure, including optional group and failure indices.
      Parameters:
      failure - The TestFailure object that encapsulates the details of the test failure
      groupIndex - The index of the group this failure belongs to, or null if not applicable
      failureIndex - The index of the failure within the group, or null 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 - The TestFailure object representing the test failure details
      groupIndex - The index of the group this failure belongs to
      failureIndex - The index of the failure within the group
    • printFailures

      public static void printFailures(TestClassFailures failures, int groupIndex)
      Prints the failures of a specific test class along with their group and failure indices.
      Parameters:
      failures - the TestClassFailures object containing the test failures associated with a specific test class
      groupIndex - the index of the group to which the test class belongs
    • printHeader

      public static void printHeader(String title)
      Prints a header with the specified title.
      Parameters:
      title - the title to print
    • printStackTrace

      public static void printStackTrace(TestFailure failure)
      Prints the stack trace of the provided test failure, if available.
      Parameters:
      failure - The TestFailure object containing the details and stack trace of the test failure to be printed
    • printSummary

      public static void printSummary(Map<String,TestClassFailures> groupedFailures)
      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 a TestClassFailures object that contains the failures for that group