Record Class TestResult

java.lang.Object
java.lang.Record
org.ek9lang.cli.TestResult
Record Components:
testProgram - The test that was executed
testType - Classification of the test (assert-based, blackbox, parameterized)
caseId - For parameterized tests: the case identifier (e.g., "hello", "edge")
passed - Whether the test passed (true) or failed (false)
duration - How long the test took to execute
output - Captured stdout from the test execution
errorOutput - Captured stderr from the test execution
errorMessage - Error message if test failed (null if passed)
exception - Exception if test threw one (null if passed or failed without exception)

record TestResult(TestProgram testProgram, TestType testType, String caseId, boolean passed, Duration duration, String output, String errorOutput, String errorMessage, Throwable exception) extends Record
Represents the result of executing a single @Test program or test case.

For parameterized tests, each case produces its own TestResult with a unique caseId. For simple blackbox and assert-based tests, caseId is null.

  • Constructor Details

    • TestResult

      TestResult(TestProgram testProgram, TestType testType, String caseId, boolean passed, Duration duration, String output, String errorOutput, String errorMessage, Throwable exception)
      Creates an instance of a TestResult record class.
      Parameters:
      testProgram - the value for the testProgram record component
      testType - the value for the testType record component
      caseId - the value for the caseId record component
      passed - the value for the passed record component
      duration - the value for the duration record component
      output - the value for the output record component
      errorOutput - the value for the errorOutput record component
      errorMessage - the value for the errorMessage record component
      exception - the value for the exception record component
  • Method Details

    • success

      static TestResult success(TestProgram testProgram, Duration duration, String output, String errorOutput)
      Create a successful test result for an assert-based test.
    • success

      static TestResult success(TestProgram testProgram, TestType testType, String caseId, Duration duration, String output, String errorOutput)
      Create a successful test result for a test case.
    • failure

      static TestResult failure(TestProgram testProgram, Duration duration, String output, String errorOutput, String errorMessage)
      Create a failed test result from an assertion or runtime error (assert-based test).
    • failure

      static TestResult failure(TestProgram testProgram, TestType testType, String caseId, Duration duration, String output, String errorOutput, String errorMessage)
      Create a failed test result for a test case.
    • exception

      static TestResult exception(TestProgram testProgram, Duration duration, String output, String errorOutput, Throwable exception)
      Create a failed test result from an exception (assert-based test).
    • exception

      static TestResult exception(TestProgram testProgram, TestType testType, String caseId, Duration duration, String output, String errorOutput, Throwable exception)
      Create a failed test result from an exception for a test case.
    • getTestName

      String getTestName()
      Get the test name for display.
    • getFullyQualifiedName

      String getFullyQualifiedName()
      Get the fully qualified test name.
    • getDisplayName

      String getDisplayName()
      Get display name including case ID for parameterized tests.
    • isParameterized

      boolean isParameterized()
      Check if this is a parameterized test case.
    • hasOutput

      boolean hasOutput()
      Check if this test has captured output.
    • hasErrorOutput

      boolean hasErrorOutput()
      Check if this test has captured error output.
    • hasException

      boolean hasException()
      Check if this test failed with an exception.
    • getSourceFile

      String getSourceFile()
      Get the source file where this test is defined.
    • 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 the compare method from their corresponding wrapper classes.
      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.
    • testProgram

      public TestProgram testProgram()
      Returns the value of the testProgram record component.
      Returns:
      the value of the testProgram record component
    • testType

      public TestType testType()
      Returns the value of the testType record component.
      Returns:
      the value of the testType record component
    • caseId

      public String caseId()
      Returns the value of the caseId record component.
      Returns:
      the value of the caseId record component
    • passed

      public boolean passed()
      Returns the value of the passed record component.
      Returns:
      the value of the passed record component
    • duration

      public Duration duration()
      Returns the value of the duration record component.
      Returns:
      the value of the duration record component
    • output

      public String output()
      Returns the value of the output record component.
      Returns:
      the value of the output record component
    • errorOutput

      public String errorOutput()
      Returns the value of the errorOutput record component.
      Returns:
      the value of the errorOutput record component
    • errorMessage

      public String errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component
    • exception

      public Throwable exception()
      Returns the value of the exception record component.
      Returns:
      the value of the exception record component