Record Class TestResult
java.lang.Object
java.lang.Record
org.ek9lang.cli.TestResult
- Record Components:
testProgram- The test that was executedtestType- 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 executeoutput- Captured stdout from the test executionerrorOutput- Captured stderr from the test executionerrorMessage- 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 Summary
ConstructorsConstructorDescriptionTestResult(TestProgram testProgram, TestType testType, String caseId, boolean passed, Duration duration, String output, String errorOutput, String errorMessage, Throwable exception) Creates an instance of aTestResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncaseId()Returns the value of thecaseIdrecord component.duration()Returns the value of thedurationrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theerrorMessagerecord component.Returns the value of theerrorOutputrecord component.Returns the value of theexceptionrecord component.(package private) static TestResultexception(TestProgram testProgram, Duration duration, String output, String errorOutput, Throwable exception) Create a failed test result from an exception (assert-based test).(package private) static TestResultexception(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.(package private) static TestResultfailure(TestProgram testProgram, Duration duration, String output, String errorOutput, String errorMessage) Create a failed test result from an assertion or runtime error (assert-based test).(package private) static TestResultfailure(TestProgram testProgram, TestType testType, String caseId, Duration duration, String output, String errorOutput, String errorMessage) Create a failed test result for a test case.(package private) StringGet display name including case ID for parameterized tests.(package private) StringGet the fully qualified test name.(package private) StringGet the source file where this test is defined.(package private) StringGet the test name for display.(package private) booleanCheck if this test has captured error output.(package private) booleanCheck if this test failed with an exception.final inthashCode()Returns a hash code value for this object.(package private) booleanCheck if this test has captured output.(package private) booleanCheck if this is a parameterized test case.output()Returns the value of theoutputrecord component.booleanpassed()Returns the value of thepassedrecord component.(package private) static TestResultsuccess(TestProgram testProgram, Duration duration, String output, String errorOutput) Create a successful test result for an assert-based test.(package private) static TestResultsuccess(TestProgram testProgram, TestType testType, String caseId, Duration duration, String output, String errorOutput) Create a successful test result for a test case.Returns the value of thetestProgramrecord component.testType()Returns the value of thetestTyperecord component.final StringtoString()Returns a string representation of this record class.
-
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 aTestResultrecord class.- Parameters:
testProgram- the value for thetestProgramrecord componenttestType- the value for thetestTyperecord componentcaseId- the value for thecaseIdrecord componentpassed- the value for thepassedrecord componentduration- the value for thedurationrecord componentoutput- the value for theoutputrecord componenterrorOutput- the value for theerrorOutputrecord componenterrorMessage- the value for theerrorMessagerecord componentexception- the value for theexceptionrecord 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
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
testProgram
Returns the value of thetestProgramrecord component.- Returns:
- the value of the
testProgramrecord component
-
testType
-
caseId
-
passed
-
duration
-
output
-
errorOutput
Returns the value of theerrorOutputrecord component.- Returns:
- the value of the
errorOutputrecord component
-
errorMessage
Returns the value of theerrorMessagerecord component.- Returns:
- the value of the
errorMessagerecord component
-
exception
-