Package io.karatelabs.core
Class ScenarioResult
java.lang.Object
io.karatelabs.core.ScenarioResult
- All Implemented Interfaces:
Comparable<ScenarioResult>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidApply @fail tag logic: invert the pass/fail result.intcompareTo(ScenarioResult other) longlonglonggetError()The failure decorated so the feature-file location travels with theThrowableitself — for surfaces that re-throw or dump the error raw (JUnit / surefire, the fluentRunnerAPI).intThe Gherkin comment immediately above the failed step (the assertion label), e.g.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.intThe 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).Get the failed step location for IDE navigation.Get the Gherkin text of the failed step, including its prefix (e.g. "* match c == null").Get the failure message with feature file path and line number for display.The failure message with the Gherkin comment label stripped from the front.The first line ofgetFailureReason()— e.g.intThe failure rendered for a performance-tool KO message:"path/to/feature.feature:LINE step text - reason".intThe author-set__idstable identity, or null when unset (derive the slug).longbooleanbooleanisFailed()booleanbooleanisPassed()booleanbooleanTrue when this scenario was aborted viakarate.abort()or had no step pass and no step fail (suite-aborted pre-run or empty scenario).voidDrop this scenario's nested call trees.voidsetAborted(boolean aborted) voidsetEndTime(long endTime) voidsetReportDisabled(boolean reportDisabled) voidsetStableId(String stableId) Set byScenarioRuntimefrom the live__idvariable before SCENARIO_EXIT fires.voidsetStartTime(long startTime) voidsetThreadName(String threadName) toJson()Convert to JSON format.
-
Field Details
-
EXPECT_TEST_TO_FAIL_BECAUSE_OF_FAIL_TAG
- See Also:
-
SUPPRESSED_FAILURE_MESSAGE
- See Also:
-
-
Constructor Details
-
ScenarioResult
-
-
Method Details
-
getStableId
The author-set__idstable identity, or null when unset (derive the slug). -
setStableId
Set byScenarioRuntimefrom the live__idvariable before SCENARIO_EXIT fires. -
setStartTime
public void setStartTime(long startTime) -
setEndTime
public void setEndTime(long endTime) -
setThreadName
-
isAborted
public boolean isAborted() -
setAborted
public void setAborted(boolean aborted) -
isReportDisabled
public boolean isReportDisabled() -
setReportDisabled
public void setReportDisabled(boolean reportDisabled) -
getScenario
-
getStepResults
-
releaseCallResults
public void releaseCallResults()Drop this scenario's nested call trees. SeeFeatureResult.releaseCallResults(). -
addStepResult
-
getStartTime
public long getStartTime() -
getEndTime
public long getEndTime() -
getThreadName
-
isPassed
public boolean isPassed() -
isFailed
public boolean isFailed() -
isSkipped
public boolean isSkipped()True when this scenario was aborted viakarate.abort()or had no step pass and no step fail (suite-aborted pre-run or empty scenario). Reported additively alongsideisPassed(); a skipped scenario is still counted as passed (preserves existing count semantics). Surfaces in reports via a synthetic@skippedtag. -
getDurationMillis
public long getDurationMillis() -
getDurationNanos
public long getDurationNanos() -
getFailureMessage
-
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
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
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
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 amatch/assertwhose 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 fromgetFailedStepText()so the single-line step text still feeds the stack-frame label and perf/KO messages. -
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
The failure message with the Gherkin comment label stripped from the front. The label is prepended tomatch/assertmessages 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
The first line ofgetFailureReason()— 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
The failure rendered for a performance-tool KO message:"path/to/feature.feature:LINE step text - reason".Only
the reason's first lineis 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 bloatsimulation.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
-
getErrorWithLocation
The failure decorated so the feature-file location travels with theThrowableitself — for surfaces that re-throw or dump the error raw (JUnit / surefire, the fluentRunnerAPI). UnlikegetError()(the untouched step error), the returnedKarateExceptioncarriespath.feature:lineon 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
Convert to JSON format. Used for HTML reports, JSONL streaming, and report aggregation. -
compareTo
- Specified by:
compareToin interfaceComparable<ScenarioResult>
-