Record Class ScenarioRunEvent

java.lang.Object
java.lang.Record
io.karatelabs.core.ScenarioRunEvent
All Implemented Interfaces:
RunEvent

public record ScenarioRunEvent(RunEventType type, ScenarioRuntime source, ScenarioResult result, long timeStamp) extends Record implements RunEvent
Scenario-level events (SCENARIO_ENTER, SCENARIO_EXIT).
  • Constructor Details

    • ScenarioRunEvent

      public ScenarioRunEvent(RunEventType type, ScenarioRuntime source, ScenarioResult result, long timeStamp)
      Creates an instance of a ScenarioRunEvent record class.
      Parameters:
      type - the value for the type record component
      source - the value for the source record component
      result - the value for the result record component
      timeStamp - the value for the timeStamp record component
  • Method Details

    • enter

      public static ScenarioRunEvent enter(ScenarioRuntime sr)
    • exit

      public static ScenarioRunEvent exit(ScenarioRuntime sr, ScenarioResult result)
    • getType

      public RunEventType getType()
      Description copied from interface: RunEvent
      Returns the event type.
      Specified by:
      getType in interface RunEvent
    • getTimeStamp

      public long getTimeStamp()
      Description copied from interface: RunEvent
      Returns the timestamp when this event occurred (epoch milliseconds).
      Specified by:
      getTimeStamp in interface RunEvent
    • toJson

      public Map<String,Object> toJson()
      Serializes a thin per-scenario envelope: identity (feature path, slug, line, refId), name, description, tags, and (on EXIT) pass/fail + duration. For outline-examples, outlineSlug + exampleIndex let receivers stitch back to the parent OUTLINE_ENTER event without denormalising outline metadata into every example.

      Step results — and any embeds attached to them by exts (e.g. openapi-match, grpc-match) — are deliberately not emitted here. They reach receivers inside FEATURE_EXIT.data.scenarioResults[i].stepResults[j].embeds[] via FeatureResult.toJson(), which already serializes the full scenario detail. Duplicating embeds onto SCENARIO_EXIT would double the on-wire bytes for typical HTTP-heavy runs without giving consumers any new information — keep them at exactly one location on the wire. See karate/docs/DESIGN.md §JSONL stream for the cross-ext convention.

      Specified by:
      toJson in interface RunEvent
    • 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.
    • type

      public RunEventType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • source

      public ScenarioRuntime source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • result

      public ScenarioResult result()
      Returns the value of the result record component.
      Returns:
      the value of the result record component
    • timeStamp

      public long timeStamp()
      Returns the value of the timeStamp record component.
      Returns:
      the value of the timeStamp record component