diff --git a/CHANGELOG.md b/CHANGELOG.md index 590dbaf..a149979 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. diff --git a/examples/parameterized-cases.json b/examples/parameterized-cases.json new file mode 100644 index 0000000..c085d8d --- /dev/null +++ b/examples/parameterized-cases.json @@ -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" + } + } + ] + } +} diff --git a/schema/ctrf.schema.json b/schema/ctrf.schema.json index 7a26a05..bf3e7bd 100644 --- a/schema/ctrf.schema.json +++ b/schema/ctrf.schema.json @@ -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 }, diff --git a/spec/ctrf.md b/spec/ctrf.md index 376623e..7d61b66 100644 --- a/spec/ctrf.md +++ b/spec/ctrf.md @@ -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. @@ -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:** @@ -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 }, @@ -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: @@ -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" + } + } + ] + } +} +``` diff --git a/tests/ctrf.test.json b/tests/ctrf.test.json index 295a9fb..fe781c7 100644 --- a/tests/ctrf.test.json +++ b/tests/ctrf.test.json @@ -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" } ] } diff --git a/tests/normative/valid-documents.test.json b/tests/normative/valid-documents.test.json index 5edd46e..e0a5efd 100644 --- a/tests/normative/valid-documents.test.json +++ b/tests/normative/valid-documents.test.json @@ -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,