Class StepResult

java.lang.Object
io.karatelabs.core.StepResult

public class StepResult extends Object
  • Method Details

    • passed

      public static StepResult passed(Step step, long startTime, long durationNanos)
    • failed

      public static StepResult failed(Step step, long startTime, long durationNanos, Throwable error)
    • skipped

      public static StepResult skipped(Step step, long startTime)
    • fakeSuccess

      public static StepResult fakeSuccess(String message, long startTime)
      Create a fake success step result (for @fail tag handling).
    • fakeFailure

      public static StepResult fakeFailure(String message, long startTime, Throwable error)
      Create a fake failure step result (for @fail tag handling).
    • hook

      public static StepResult hook(String hookName, StepResult.Status status, long startTime, long durationNanos, Throwable error)
      Create a synthetic step result representing a beforeScenario / afterScenario hook. The hook name becomes the step text; nested karate.call() results and logs are set by the caller via the existing setters.
    • synthetic

      public static StepResult synthetic(String text, StepResult.Status status, long startTime, Throwable error)
      Create a synthetic step result that an out-of-band producer appends to a scenario at runtime (not parsed from a .feature). Unlike fakeSuccess(java.lang.String, long)/fakeFailure(java.lang.String, long, java.lang.Throwable) — which reuse the log as the step text — text is the step's display text and log/embeds stay separate and optional. A FAILED synthetic step is reported as a failed step row and, because ScenarioResult.isFailed() scans the step list, fails its scenario without a throw; a PASSED one is a green step row that does not affect the verdict. The optional error surfaces as the failed step's message.
      See Also:
    • getStep

      public Step getStep()
    • getStatus

      public StepResult.Status getStatus()
    • getStartTime

      public long getStartTime()
    • getDurationNanos

      public long getDurationNanos()
    • getDurationMillis

      public double getDurationMillis()
    • getError

      public Throwable getError()
    • getLog

      public String getLog()
      The step's captured output — HTTP request / response blocks, print.

      Null once the feature has finished, unless the run set Runner.Builder.retainStepLogs(true). Every report format is generated while the result is still whole; the text is dropped afterwards because a SuiteResult holds every feature for the whole run and this is the bulk of what that costs. See FeatureResult.releaseStepLogs().

    • setLog

      public void setLog(String log)
    • getSyntheticText

      public String getSyntheticText()
      The display text of a synthetic step (synthetic(java.lang.String, io.karatelabs.core.StepResult.Status, long, java.lang.Throwable)); null for a parsed/hook step.
    • appendLog

      public void appendLog(String message)
    • getEmbeds

      public List<StepResult.Embed> getEmbeds()
      Assets attached to this step — screenshots, documents, ext payloads.

      Null once the feature has finished, unless the run set Runner.Builder.retainStepLogs(true) — same release, same reason, and these are the larger half because an embed holds raw bytes. See FeatureResult.releaseStepLogs().

    • addEmbed

      public void addEmbed(StepResult.Embed embed)
    • getCallResults

      public List<FeatureResult> getCallResults()
    • setCallResults

      public void setCallResults(List<FeatureResult> callResults)
    • hasCallResults

      public boolean hasCallResults()
    • getHookName

      public String getHookName()
    • isHook

      public boolean isHook()
    • isPassed

      public boolean isPassed()
    • isFailed

      public boolean isFailed()
    • isSkipped

      public boolean isSkipped()
    • getErrorMessage

      public String getErrorMessage()
    • toJson

      public Map<String,Object> toJson()
      Convert to JSON format (V1 nested structure). Uses nested `step` and `result` objects for V1 compatibility.