Package org.pkl.core
Record Class TestResults
java.lang.Object
java.lang.Record
org.pkl.core.TestResults
- Record Components:
moduleName- The name of the module that was tested.displayUri- A location URI formatted to be displayed.facts- The result of testing facts.examples- The result of testing examples.logs- The log output resulting from running the test.error- An error that arose from evaluating the test module itself.If non-null,
factsandexamplesare guaranteed to have 0 results.
public record TestResults(String moduleName, String displayUri, TestResults.TestSectionResults facts, TestResults.TestSectionResults examples, String logs, @Nullable TestResults.Error error)
extends Record
The results of testing a Pkl test module.
A test module is a module that amends pkl:test, and is evaluated with Evaluator.evaluateTest(ModuleSource, boolean).
Test results have two sections; facts, and examples. Each section has multiple individual results, which themselves contain individual assertions.
- Since:
- 0.27.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic final recordIndicates that an exception was thrown when evaluating the assertion.static final recordIndicates that an assertion failed.static final recordThe result of a single test.static enumstatic final recordThe results of either facts or examples. -
Constructor Summary
ConstructorsConstructorDescriptionTestResults(String moduleName, String displayUri, TestResults.TestSectionResults facts, TestResults.TestSectionResults examples, String logs, @Nullable TestResults.Error error) Creates an instance of aTestResultsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thedisplayUrirecord component.final booleanIndicates whether some other object is "equal to" this one.error()Returns the value of theerrorrecord component.examples()Returns the value of theexamplesrecord component.facts()Returns the value of thefactsrecord component.booleanfailed()Whether the test in aggregate has failed or not.final inthashCode()Returns a hash code value for this object.booleanWhether the test result has failed due to examples being written.logs()Returns the value of thelogsrecord component.Returns the value of themoduleNamerecord component.final StringtoString()Returns a string representation of this record class.intThe total number of assertions between facts and examples.intThe total number of individual assertions that have failed.intThe total number of failed test results.intThe total number of tests between facts and examples.
-
Constructor Details
-
TestResults
public TestResults(String moduleName, String displayUri, TestResults.TestSectionResults facts, TestResults.TestSectionResults examples, String logs, @Nullable @Nullable TestResults.Error error) Creates an instance of aTestResultsrecord class.- Parameters:
moduleName- the value for themoduleNamerecord componentdisplayUri- the value for thedisplayUrirecord componentfacts- the value for thefactsrecord componentexamples- the value for theexamplesrecord componentlogs- the value for thelogsrecord componenterror- the value for theerrorrecord component
-
-
Method Details
-
totalTests
public int totalTests()The total number of tests between facts and examples. -
totalFailures
public int totalFailures()The total number of failed test results.A
TestResults.TestResulthas failed if any of its assertions have aTestResults.Failureor anTestResults.Error. -
totalAsserts
public int totalAsserts()The total number of assertions between facts and examples. -
totalAssertsFailed
public int totalAssertsFailed()The total number of individual assertions that have failed.A single test can have multiple failed assertions.
-
failed
public boolean failed()Whether the test in aggregate has failed or not.An individual
TestResults.TestResulthas failed if any of its assertions have aTestResults.Failureor anTestResults.Error. -
isExampleWrittenFailure
public boolean isExampleWrittenFailure()Whether the test result has failed due to examples being written.Returns
trueif and only if there are failures, and all failures are due to examples being written. -
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. -
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. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
moduleName
Returns the value of themoduleNamerecord component.- Returns:
- the value of the
moduleNamerecord component
-
displayUri
Returns the value of thedisplayUrirecord component.- Returns:
- the value of the
displayUrirecord component
-
facts
Returns the value of thefactsrecord component.- Returns:
- the value of the
factsrecord component
-
examples
Returns the value of theexamplesrecord component.- Returns:
- the value of the
examplesrecord component
-
logs
Returns the value of thelogsrecord component.- Returns:
- the value of the
logsrecord component
-
error
Returns the value of theerrorrecord component.- Returns:
- the value of the
errorrecord component
-