Class FeatureResult

java.lang.Object
io.karatelabs.core.FeatureResult

public class FeatureResult extends Object
  • Constructor Details

    • FeatureResult

      public FeatureResult(Feature feature)
  • Method Details

    • fromException

      public static FeatureResult fromException(Feature feature, Throwable error, long startTime)
      Create a failed FeatureResult from an exception that occurred during feature execution. This is used when an unexpected error prevents normal scenario execution, such as failures in dynamic expression evaluation for Scenario Outlines.
      Parameters:
      feature - the feature that failed
      error - the exception that caused the failure
      startTime - the start time of the feature execution
      Returns:
      a FeatureResult marked as failed with a synthetic scenario containing the error
    • getFeature

      public Feature getFeature()
    • setStartTime

      public void setStartTime(long startTime)
    • setEndTime

      public void setEndTime(long endTime)
    • getStartTime

      public long getStartTime()
    • getEndTime

      public long getEndTime()
    • getCallDepth

      public int getCallDepth()
    • setCallDepth

      public void setCallDepth(int callDepth)
    • getLoopIndex

      public int getLoopIndex()
    • setLoopIndex

      public void setLoopIndex(int loopIndex)
    • getCallArg

      public Object getCallArg()
    • setCallArg

      public void setCallArg(Object callArg)
    • getResultVariables

      public Map<String,Object> getResultVariables()
    • setResultVariables

      public void setResultVariables(Map<String,Object> resultVariables)
    • addScenarioResult

      public void addScenarioResult(ScenarioResult sr)
    • getScenarioResults

      public List<ScenarioResult> getScenarioResults()
    • sortScenarioResults

      public void sortScenarioResults()
      Sort scenario results by section index, example index, and line number. This ensures deterministic ordering in reports regardless of parallel execution order.
    • getScenarioCount

      public int getScenarioCount()
    • getPassedCount

      public int getPassedCount()
    • getFailedCount

      public int getFailedCount()
    • getSkippedCount

      public int getSkippedCount()
    • getPassedRate

      public Integer getPassedRate()
      Pass rate as an integer percentage 0–100, or null when no scenarios executed. Denominator is passedCount + failedCount — mirrors the HTML report's per-feature calc so JSONL consumers and the HTML view agree.
    • isPassed

      public boolean isPassed()
    • releaseCallResults

      public void releaseCallResults()
      Drop the nested karate.call() result trees hanging off this feature's steps.

      Every call attaches the callee's entire FeatureResult to the calling StepResult, and a SuiteResult holds every feature for the whole run — so without this the live set grows with total scenarios times calls per scenario, and a long suite exhausts the heap on retention alone rather than on anything it is actually doing.

      Called once a feature has completed and every listener has consumed it, so the HTML report — which extracts its page model synchronously — keeps full nested step detail. What is lost is the ability to walk into a called feature's steps from a SuiteResult after the run; Runner.Builder.retainCallResults(true) keeps that for callers who need it.

      Only the nesting is dropped. Each step's own status, timing, log and embeds are untouched, so summaries, failure messages and the report itself are unaffected.

    • releaseStepLogs

      public void releaseStepLogs()
      Drop each step's captured log text and embedded assets, once every consumer has had them.

      This is the bulk of what a suite retains. The log holds the rendered HTTP request and response for every step — bodies included — and an StepResult.Embed holds raw byte[], which for a UI suite means a screenshot per failed step. Both are kept only so the report writers can render them, yet a SuiteResult holds every feature until the run ends, so they stay reachable for hours after the last thing that reads them. Measured on a 350,000-scenario soak with all four report formats on: ~3.2 KB retained per scenario, of which roughly 70% was this text — and that share grows with payload size, which is why a suite of scenarios making several calls with large bodies is where this stops being footprint and becomes an OOM.

      Called from the same place as releaseCallResults() and under the same precondition — after onFeatureEnd, so HTML, Cucumber JSON and JUnit XML have all serialized the feature, and after FEATURE_EXIT, where the JSONL stream carries toJson() (non-JSON embeds having already been externalized to embeds/ by Suite.fireEvent, so the record carries file references). Nothing downstream reads either field later; what is lost is the ability to inspect a step's log or embeds from a SuiteResult after the run, which Runner.Builder.retainStepLogs(true) keeps for callers who need it.

      Status, timing, failure messages and counts are untouched, so summaries, the console output and every report are unaffected.

    • isFailed

      public boolean isFailed()
    • isEmpty

      public boolean isEmpty()
    • getDurationMillis

      public long getDurationMillis()
    • getDisplayName

      public String getDisplayName()
    • getFailureMessage

      public String getFailureMessage()
    • getFailureMessageForDisplay

      public String getFailureMessageForDisplay()
      The failed step's path/to/feature.feature:LINE step text, or null when there is no failure. See ScenarioResult.getFailureMessageForDisplay().
    • getFailureReason

      public String getFailureReason()
      The failure reason without the Gherkin comment label, or null when there is no failure. See ScenarioResult.getFailureReason().
    • getFailureReasonSummary

      public String getFailureReasonSummary()
      The one-line "why" of the failure, e.g. "match failed: EQUALS", or null when there is no failure. See ScenarioResult.getFailureReasonSummary().
    • getFailedStepComment

      public String getFailedStepComment()
      The Gherkin comment above the failed step (the assertion label), or null when there is none. See ScenarioResult.getFailedStepComment().
    • getFailedStepLine

      public int getFailedStepLine()
      The failed step's line number, or -1 when there is no failure or the failure is not tied to a parsed step (hook / synthetic). Lets a caller that already knows the feature path — the Gatling executor logs the path exactly as the simulation declared it — append :LINE without swapping in the absolute path.
    • toJson

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

      public void printSummary()
      Print a summary of this feature's results to the console.
    • printSummary

      public void printSummary(boolean dryRun)
      Parameters:
      dryRun - parse-only (-D) — every scenario is skipped and skips count toward passed, so the status word must say "parsed", not "passed".