Execution Lifecycle
This page documents the runtime path used by createTestRunAction, executeTestRun, and ProcessManager.
Request payload (testRunSchema)
Section titled “Request payload (testRunSchema)”| Field | Type | Required | Meaning |
|---|---|---|---|
name | string | Yes | Human-readable run name. Must be unique in TestRun. |
environmentId | string | Yes | Database ID for the target Environment. |
tags | string[] | Conditional | Tag IDs for tag-based selection mode. |
testCases | { testCaseId: string }[] | Conditional | Explicit case IDs when tag-based selection is not used. |
testWorkersCount | number | No | Parallel worker count. Minimum value is 1. |
browserEngine | BrowserEngine enum | Yes | CHROMIUM, FIREFOX, or WEBKIT. |
Selection rule: at least one of tags or testCases must be provided.
1. Run creation and scope resolution
Section titled “1. Run creation and scope resolution”- Validate payload with
testRunSchema. - Enforce unique run name (
checkUniqueName). - Resolve target environment from
environmentId; return400if not found. - Determine filtering mode:
- Tag mode:
tags.length > 0 - Test-case mode:
testCases.length > 0 && tags.length === 0
- Tag mode:
- Build execution scope:
- Tag mode: collect matching test cases from case-level tags and suite-level tags.
- Test-case mode: fetch selected cases, extract
IDENTIFIERtags, and reject request if no identifier tags exist.
- Create
TestRunwith:status = RUNNINGresult = PENDING- Connected tags and created
TestRunTestCaserows for scoped cases.
2. Process launch (executeTestRun)
Section titled “2. Process launch (executeTestRun)”createTestRunAction invokes executeTestRun with:
| Parameter | Type | Meaning |
|---|---|---|
testRunId | string | External run identifier (runId), used as process key and artifact prefix. |
environment | Environment | Full environment record; name is exported to process env. |
tags | Tag[] | Tags converted into Cucumber tag expression (or combined). |
testWorkersCount | number | Controls --parallel argument when greater than 1. |
browserEngine | BrowserEngine | Mapped to Playwright browser name (chromium/firefox/webkit). |
headless | boolean | Passed as HEADLESS env var, defaults to true. |
Execution steps:
- Generate report path:
src/tests/reports/cucumber-{runId}-{timestamp}.json. - Set process env vars:
ENVIRONMENT: environment name (string)HEADLESS:"true"or"false"(string)BROWSER: browser name (string)REPORT_PATH: absolute cucumber output path (string)
- Build Cucumber args:
-t <tagExpression>when tags exist--parallel <count>when worker count > 1
- Spawn
npx cucumber-js ...usingspawnTask. - Register process in
ProcessManagerundertestRunId. - Attach process exit handler that unregisters process immediately.
3. Runtime events and trace artifacts
Section titled “3. Runtime events and trace artifacts”Hooks in src/tests/hooks/hooks.ts emit structured JSON events to stdout:
| Field | Type | Meaning |
|---|---|---|
event | "scenario::end" | Event discriminator parsed by ProcessManager. |
data.scenarioName | string | Cucumber scenario name. |
data.status | "passed" | "failed" | "skipped" | "unknown" | Scenario outcome derived from step status progression. |
data.tracePath | string | undefined | ZIP path for failed scenarios (src/tests/reports/traces/*.zip). |
Flow:
- Hooks track per-scenario status during execution.
- On scenario completion, hooks emit
scenario::endJSON. ProcessManagerparses stdout/stderr and re-emitsscenario::end.createTestRunActionlistener maps status and updates matchingTestRunTestCase.- Scenario matching uses bracket prefix (
[Test Case Title]) with fallback handling for tag-only runs.
4. Completion, logs, and report persistence
Section titled “4. Completion, logs, and report persistence”- Wait for spawned process completion (
waitForTask). - Normalize captured stdout/stderr into
LogEntry[]and persist inTestRunLog. - Finalize run status/result:
- Exit code
0->COMPLETED/PASSED - Non-zero ->
COMPLETED/FAILED - Preserve cancelled states when cancellation already occurred.
- Exit code
- Persist report tree using
storeReportFromFile(runId, reportPath):Report->ReportFeature->ReportScenario->ReportStep/ReportHook- Link back to run cases through
ReportTestCase.
- Trigger metrics updates and revalidation paths for UI consistency.
Flow diagram for this lifecycle:
#direction: down#spacing: 60#stroke: #64748b#fill: #f8fafc[UI] -> [createTestRunAction][createTestRunAction] -> [DB: Create TestRun + rows][createTestRunAction] -> [test-run-executor][test-run-executor] -> [ProcessManager: register][test-run-executor] -> [Cucumber Hooks: launch][Cucumber Hooks: launch] -> [ProcessManager: emit scenario::end][ProcessManager: emit scenario::end] -> [createTestRunAction][createTestRunAction] -> [DB: update status + tracePath][test-run-executor] -> [createTestRunAction: process exit][createTestRunAction] -> [report-actions: storeReportFromFile][report-actions: storeReportFromFile] -> [DB: report hierarchy][createTestRunAction] -> [DB: finalize run + logs]Failure and guardrail behavior
Section titled “Failure and guardrail behavior”- Reject run when both
tagsandtestCasesare empty. - Reject explicit case mode when selected cases have no
IDENTIFIERtags. - Skip report generation when run is cancelled.
- Return structured
404when report file is missing at ingest time.