Class ScenarioResult

java.lang.Object
io.karatelabs.core.ScenarioResult
All Implemented Interfaces:
Comparable<ScenarioResult>

public class ScenarioResult extends Object implements Comparable<ScenarioResult>
  • Field Details

  • Constructor Details

    • ScenarioResult

      public ScenarioResult(Scenario scenario)
  • Method Details

    • getStableId

      public String getStableId()
      The author-set __id stable identity, or null when unset (derive the slug).
    • setStableId

      public void setStableId(String stableId)
      Set by ScenarioRuntime from the live __id variable before SCENARIO_EXIT fires.
    • setStartTime

      public void setStartTime(long startTime)
    • setEndTime

      public void setEndTime(long endTime)
    • setThreadName

      public void setThreadName(String threadName)
    • isAborted

      public boolean isAborted()
    • setAborted

      public void setAborted(boolean aborted)
    • isReportDisabled

      public boolean isReportDisabled()
    • setReportDisabled

      public void setReportDisabled(boolean reportDisabled)
    • getScenario

      public Scenario getScenario()
    • getStepResults

      public List<StepResult> getStepResults()
    • releaseCallResults

      public void releaseCallResults()
      Drop this scenario's nested call trees. See FeatureResult.releaseCallResults().
    • addStepResult

      public void addStepResult(StepResult sr)
    • getStartTime

      public long getStartTime()
    • getEndTime

      public long getEndTime()
    • getThreadName

      public String getThreadName()
    • isPassed

      public boolean isPassed()
    • isFailed

      public boolean isFailed()
    • isSkipped

      public boolean isSkipped()
      True when this scenario was aborted via karate.abort() or had no step pass and no step fail (suite-aborted pre-run or empty scenario). Reported additively alongside isPassed(); a skipped scenario is still counted as passed (preserves existing count semantics). Surfaces in reports via a synthetic @skipped tag.
    • getDurationMillis

      public long getDurationMillis()
    • getDurationNanos

      public long getDurationNanos()
    • getFailureMessage

      public String getFailureMessage()
    • getFailedStepLocation

      public String getFailedStepLocation()
      Get the failed step location for IDE navigation. Format: "path/to/feature.feature:LINE" (standard IDE clickable format) Uses absolute path when available for better IDE compatibility.
      Returns:
      location string "path:line", or null if no failure
    • getFailedStepLine

      public int getFailedStepLine()
      The 1-indexed line of the failed step, or -1 when there is no failure or the failure is not tied to a parsed step (hook / synthetic).
    • getFailedStepComment

      public String getFailedStepComment()
      The Gherkin comment immediately above the failed step (the assertion label), e.g. "# user profile should match expected values", or null if the step has no comment. The console summary renders this above the step line — where it sits in the feature — and strips the same label from the front of the failure message so it isn't shown twice.
    • getFailedStepText

      public String getFailedStepText()
      Get the Gherkin text of the failed step, including its prefix (e.g. "* match c == null"). Useful for error output so the reader can see the offending source line without opening the feature file.
      Returns:
      " ", or null if no failure
    • getFailedStepDocString

      public String getFailedStepDocString()
      The docstring (triple-quoted block) of the failed step, rendered with its """ delimiters exactly as it appears in the feature, or null if the step has none. Rendered under the step line in the console summary so a match/assert whose RHS is a docstring (e.g. * match actual == followed by a JSON block) shows the expected block instead of a step line that looks truncated. Kept separate from getFailedStepText() so the single-line step text still feeds the stack-frame label and perf/KO messages.
    • getFailureMessageForDisplay

      public String getFailureMessageForDisplay()
      Get the failure message with feature file path and line number for display. Format: "path/to/feature.feature:LINE step text"
      Returns:
      formatted failure message, or null if no failure
    • getFailureReason

      public String getFailureReason()
      The failure message with the Gherkin comment label stripped from the front. The label is prepended to match/assert messages so it travels with the error, but every surface that renders the comment separately (the console summary, the Gatling failure log) would otherwise show it twice.
      Returns:
      the failure reason, or null if there is no failure
    • getFailureReasonSummary

      public String getFailureReasonSummary()
      The first line of getFailureReason() — e.g. "match failed: EQUALS" — capped at 200 characters, or null if there is no failure. The one-line "why" for surfaces that must stay short: a log summary line, or a KO message that a performance tool groups by.
    • getPerfFailureMessage

      public String getPerfFailureMessage()
      The failure rendered for a performance-tool KO message: "path/to/feature.feature:LINE step text - reason".

      Only the reason's first line is included. Gatling groups its errors table by this exact string, so the full match diff — which embeds the actual values, different for every virtual user — would make each KO a unique row and bloat simulation.log. The full detail belongs in the failure log instead. Falls back to the reason alone when the failure is not tied to a parsed step (hook / synthetic), and null when there is no failure.

    • getError

      public Throwable getError()
    • getErrorWithLocation

      public Throwable getErrorWithLocation()
      The failure decorated so the feature-file location travels with the Throwable itself — for surfaces that re-throw or dump the error raw (JUnit / surefire, the fluent Runner API). Unlike getError() (the untouched step error), the returned KarateException carries path.feature:line on its own message line (the IDE-hyperlinkable shape) and a synthetic <feature> frame on top of the preserved original stack. Falls back to the raw error when the failure is not tied to a parsed step (hook / synthetic), and null when there is no failure.
      See Also:
    • getPassedCount

      public int getPassedCount()
    • getFailedCount

      public int getFailedCount()
    • getSkippedCount

      public int getSkippedCount()
    • applyFailTag

      public void applyFailTag()
      Apply @fail tag logic: invert the pass/fail result. If the scenario failed (as expected with @fail), mark it as passed. If the scenario passed (unexpectedly with @fail), mark it as failed.
    • isFailTagApplied

      public boolean isFailTagApplied()
    • toJson

      public Map<String,Object> toJson()
      Convert to JSON format. Used for HTML reports, JSONL streaming, and report aggregation.
    • compareTo

      public int compareTo(ScenarioResult other)
      Specified by:
      compareTo in interface Comparable<ScenarioResult>