Package io.karatelabs.core
Class RunUtils
java.lang.Object
io.karatelabs.core.RunUtils
Shared helpers for run-event JSON shaping — cross-run-stable slug computation
and tag-text extraction. Used by
FeatureRunEvent, ScenarioRunEvent,
and OutlineRunEvent to keep identity + tag fields consistent across the
JSONL stream so receivers can stitch by slug without re-reading source files.
Slug resolution:
- Feature → its relative path.
- Named scenario →
<feature-path>:<scenario-name>. - Unnamed scenario →
<feature-path>::L<line>. - Outline → name-based against feature path (line fallback).
- Outline-example →
<outline-slug>:<exampleIndex>.
Rename / refactor stability is an opt-in via the author-set __id
variable (a sibling of __row/__num), captured and applied in
ScenarioRunEvent: when a scenario binds a non-blank __id it
overrides the derived slug verbatim. An earlier design instead used an
@id=<value> tag as a first-precedence override; that was removed
because @id= is a generic tag many teams already use for their own
conventions (ticket IDs, story keys, internal nomenclature), and silently
co-opting it into our cross-run-identity model coupled their tag conventions
to our data model in a way they never asked for. __id is explicit —
the author binds it on purpose — so it carries no such surprise.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringeffectiveSlug(String stableId, Scenario scenario, Feature feature) The scenario's effective identity for the wire: a non-blank author-setstableId(__id) wins verbatim; otherwise the slug derives from feature path + scenario name.static StringfeatureSlug(Feature feature) mergedTagTexts(List<Tag> a, List<Tag> b) Concatenate text from two Tag lists (feature-level + outline-level for outlines that don't exposegetTagsEffective).static StringoutlineSlug(ScenarioOutline outline, Feature feature) static ScenarioOutlineparentOutline(Scenario scenario) Returns the parent ScenarioOutline if the scenario was generated from one, else null.scenarioIdentity(Scenario scenario, String stableId) The scenario's shared identity + metadata fields — name, slug, description, line, section/example indices, and example data.static StringscenarioSlug(Scenario scenario, Feature feature)
-
Method Details
-
featureSlug
-
effectiveSlug
The scenario's effective identity for the wire: a non-blank author-setstableId(__id) wins verbatim; otherwise the slug derives from feature path + scenario name. One rule, shared by every emit site —ScenarioResult.toJson(),ScenarioRunEvent.toJson()andkarate.scenario.slug(KarateJsBase) — so they can never diverge.stableIdis resolved once, while the engine is live, byScenarioRuntime.resolveStableId(). -
scenarioIdentity
The scenario's shared identity + metadata fields — name, slug, description, line, section/example indices, and example data. One routine behind both thekarate.scenarioJS API (KarateJsBase.getScenarioData) and theScenarioResultJSONL / report payload (ScenarioResult.toJson()), so the two can never drift. Callers layer their purpose-specific fields on the returned (mutable) map:ScenarioResultadds status / timing / steps / tags;ScenarioRunEventkeeps its own envelope (feature path, callDepth, redacted description, outline stitching) since those are wire-only.stableIdis the resolved__id(null → derive the slug).descriptionis the raw value; redaction is a wire concern applied by the event, not here. -
scenarioSlug
-
outlineSlug
-
parentOutline
Returns the parent ScenarioOutline if the scenario was generated from one, else null. -
tagTexts
-
mergedTagTexts
Concatenate text from two Tag lists (feature-level + outline-level for outlines that don't exposegetTagsEffective).
-