Record Class TestFailure

java.lang.Object
java.lang.Record
rife.bld.extension.junitreporter.TestFailure
Record Components:
testName - the test method name; never null
displayName - the JUnit display name extracted from system-out; empty string if not present
className - the fully qualified test class name; never null
failureType - the exception class name from the type attribute; never null
failureMessage - the failure message from the message attribute; never null
stackTrace - the stack trace content of the failure or error element; empty string if not present
time - the execution time in seconds from the time attribute; must be >= 0
All Implemented Interfaces:
Comparable<TestFailure>

public record TestFailure(String testName, String displayName, String className, String failureType, String failureMessage, String stackTrace, double time) extends Record implements Comparable<TestFailure>
Immutable record representing a test case failure extracted from JUnit XML.

Instances are naturally ordered by class name, then test name for consistent sorting within TestClassFailures.

Since:
1.0
Author:
Erik C. Thauvin
  • Constructor Details

    • TestFailure

      public TestFailure(String testName, String displayName, String className, String failureType, String failureMessage, String stackTrace, double time)
      Constructs a new TestFailure instance.

      Normalizes null values for displayName and stackTrace to empty strings.

      Parameters:
      testName - the test method name; must not be null
      displayName - the JUnit display name; may be null, normalized to empty string
      className - the fully qualified test class name; must not be null
      failureType - the exception class name; must not be null
      failureMessage - the failure message; must not be null
      stackTrace - the stack trace; may be null, normalized to empty string
      time - the execution time in seconds; must be >= 0
      Throws:
      NullPointerException - if testName, className, failureType, or failureMessage is null
      IllegalArgumentException - if time is negative
  • Method Details

    • compareTo

      public int compareTo(TestFailure other)
      Compares this failure to another by class name, then test name.

      This ordering is consistent with equals and ensures failures are grouped by class when sorted.

      Specified by:
      compareTo in interface Comparable<TestFailure>
      Parameters:
      other - the other TestFailure to compare to
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • testName

      public String testName()
      Returns the value of the testName record component.
      Returns:
      the value of the testName record component
    • displayName

      public String displayName()
      Returns the value of the displayName record component.
      Returns:
      the value of the displayName record component
    • className

      public String className()
      Returns the value of the className record component.
      Returns:
      the value of the className record component
    • failureType

      public String failureType()
      Returns the value of the failureType record component.
      Returns:
      the value of the failureType record component
    • failureMessage

      public String failureMessage()
      Returns the value of the failureMessage record component.
      Returns:
      the value of the failureMessage record component
    • stackTrace

      public String stackTrace()
      Returns the value of the stackTrace record component.
      Returns:
      the value of the stackTrace record component
    • time

      public double time()
      Returns the value of the time record component.
      Returns:
      the value of the time record component