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, facts and examples are 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
  • Constructor Details

  • 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.TestResult has failed if any of its assertions have a TestResults.Failure or an TestResults.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.TestResult has failed if any of its assertions have a TestResults.Failure or an TestResults.Error.

    • isExampleWrittenFailure

      public boolean isExampleWrittenFailure()
      Whether the test result has failed due to examples being written.

      Returns true if and only if there are failures, and all failures are due to examples being written.

    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • moduleName

      public String moduleName()
      Returns the value of the moduleName record component.
      Returns:
      the value of the moduleName record component
    • displayUri

      public String displayUri()
      Returns the value of the displayUri record component.
      Returns:
      the value of the displayUri record component
    • facts

      Returns the value of the facts record component.
      Returns:
      the value of the facts record component
    • examples

      public TestResults.TestSectionResults examples()
      Returns the value of the examples record component.
      Returns:
      the value of the examples record component
    • logs

      public String logs()
      Returns the value of the logs record component.
      Returns:
      the value of the logs record component
    • error

      Returns the value of the error record component.
      Returns:
      the value of the error record component