Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Clarified parameterized case identity, rename and path scopes, and execution identity across coordinated retry processes.

- Defined parameterized test cases and consistently distinguished test cases, test objects, and executions throughout the specification and schema descriptions without changing execution or retry semantics.

- Updated UUID references to RFC 9562 and clarified optional deterministic UUID generation for `testId`.
Expand Down
42 changes: 42 additions & 0 deletions examples/parameterized-cases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"reportFormat": "CTRF",
"specVersion": "0.2.0",
"runId": "example-parameterized-run",
"results": {
"tool": {
"name": "example-runner"
},
"summary": {
"tests": 2,
"passed": 2,
"failed": 0,
"skipped": 0,
"pending": 0,
"other": 0,
"start": 1700000000000,
"stop": 1700000000020
},
"tests": [
{
"name": "login",
"testId": "login-case-alice",
"executionId": "login-execution-alice",
"status": "passed",
"duration": 10,
"parameters": {
"username": "alice"
}
},
{
"name": "login",
"testId": "login-case-bob",
"executionId": "login-execution-bob",
"status": "passed",
"duration": 10,
"parameters": {
"username": "bob"
}
}
]
}
}
4 changes: 2 additions & 2 deletions schema/ctrf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@
"minLength": 1
},
"testId": {
"description": "Stable identifier for the test case. Should be derived from stable test attributes when generated by a producer",
"description": "Stable identifier for the test case across runs within the producer's documented scope",
"type": "string",
"minLength": 1
},
"executionId": {
"description": "Unique identifier for this specific execution of the test case within a run. UUID recommended",
"description": "Identifier for one execution lifecycle of a test case within a run, including coordinated retries. UUID recommended",
"type": "string",
"minLength": 1
},
Expand Down
72 changes: 69 additions & 3 deletions spec/ctrf.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,14 @@ If present, it MUST be a non-empty string.
When generated by a producer, `testId` SHOULD be derived from stable test attributes such as file path, suite path, and test name.
A producer MAY use a canonical string directly, or MAY derive a deterministic identifier from it, such as a UUID generated deterministically in accordance with [RFC9562], or a hash.

For parameterized tests, distinct test cases SHOULD have distinct `testId` values within the producer's documented scope. Retries of the same case SHOULD retain its `testId`.

The producer chooses its identity scheme. Case-defining parameter values, stable framework identifiers, or explicit case keys MAY be used; producers are not required to serialize parameter values to construct an identifier. Contextual parameters need not participate in case identity.

An index-based identifier is suitable only when it reliably identifies the same case within the documented scope. If reordering the data source makes an existing identifier refer to a different case, documenting that ordering limitation does not itself establish stability.

Producers SHOULD preserve `testId` across renames and file moves where their identity mechanism supports it. Name- or path-derived identifiers MAY change after a refactor; producers are not required to detect renames or moves or maintain continuity beyond their documented scope.

Consumers MUST treat the `testId` value as opaque.
Consumers MUST NOT assume that `testId` values generated by different producers are globally comparable unless the producers document a shared generation scheme.

Expand All @@ -925,6 +933,12 @@ If present, it MUST be a non-empty string.
UUID is RECOMMENDED.
`executionId` SHOULD be unique across executions and SHOULD NOT be reused across runs.

Known attempts of one coordinated execution SHOULD share an `executionId`, including when attempts run in separate processes or their reports remain separate. A merged result for that execution SHOULD retain the same `executionId`. Each distinct report document has its own document identity as defined in Section 5.3.

An independent execution of the same test case SHOULD have a different `executionId`. Merging reports does not itself establish that their executions are retries; that relationship comes from the coordinated workflow.

`testId` identifies the case across runs, while `executionId` identifies one execution lifecycle, including its retries. See Appendix D.7 for parameterized cases.

### 9.3.1. `attemptId`

**Description:**
Expand Down Expand Up @@ -2247,12 +2261,12 @@ to this specification.
"minLength": 1
},
"testId": {
"description": "Stable identifier for the test case. Should be derived from stable test attributes when generated by a producer",
"description": "Stable identifier for the test case across runs within the producer's documented scope",
"type": "string",
"minLength": 1
},
"executionId": {
"description": "Unique identifier for this specific execution of the test case within a run. UUID recommended",
"description": "Identifier for one execution lifecycle of a test case within a run, including coordinated retries. UUID recommended",
"type": "string",
"minLength": 1
},
Expand Down Expand Up @@ -2847,7 +2861,7 @@ tests/auth/login.test.ts::auth > login::user can log in

Producers MAY also derive a deterministic identifier from the canonical string, such as a UUID generated deterministically in accordance with [RFC9562], or a hash.

This approach ensures that the same test case retains the same `testId` across runs, enabling consumers to analyze historical trends, flakiness, and stability.
Stable input selection lets the same test case retain its `testId` across runs within the producer's documented scope. For parameterized tests, the scheme SHOULD distinguish case-defining parameter combinations as described in Section 9.2. Stable framework identifiers or explicit case keys MAY be used instead of name- and path-based generation; no particular algorithm or serialization of parameter values is required.

When generating deterministic test identifiers, producers SHOULD:

Expand Down Expand Up @@ -3556,3 +3570,55 @@ The `ctrf.` and `ctrf/` namespace prefixes are reserved for CTRF-defined extensi
}
}
```


### D.7. Parameterized Test Cases

These cases share the same test logic and display name but have different case-defining inputs. The producer supplies distinct stable case keys; CTRF does not require deriving identifiers from the displayed parameter values. A retry of either case would retain its `testId` and coordinated `executionId`.

This example matches `examples/parameterized-cases.json`.

```json title="Parameterized test cases"
{
"reportFormat": "CTRF",
"specVersion": "0.2.0",
"runId": "example-parameterized-run",
"results": {
"tool": {
"name": "example-runner"
},
"summary": {
"tests": 2,
"passed": 2,
"failed": 0,
"skipped": 0,
"pending": 0,
"other": 0,
"start": 1700000000000,
"stop": 1700000000020
},
"tests": [
{
"name": "login",
"testId": "login-case-alice",
"executionId": "login-execution-alice",
"status": "passed",
"duration": 10,
"parameters": {
"username": "alice"
}
},
{
"name": "login",
"testId": "login-case-bob",
"executionId": "login-execution-bob",
"status": "passed",
"duration": 10,
"parameters": {
"username": "bob"
}
}
]
}
}
```
5 changes: 5 additions & 0 deletions tests/ctrf.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@
"tests": [{ "name": "test", "status": "passed", "duration": 100 }]
}
}
},
{
"description": "Parameterized cases have distinct case and execution identities",
"valid": true,
"dataPath": "../examples/parameterized-cases.json"
}
]
}
5 changes: 5 additions & 0 deletions tests/normative/valid-documents.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
}
}
},
{
"description": "Parameterized cases have distinct case and execution identities",
"valid": true,
"dataPath": "../../examples/parameterized-cases.json"
},
{
"description": "Previous attempt threadId differs from the final attempt threadId",
"valid": true,
Expand Down
Loading