42.3 Requirements that can be tested
What you will learn
- Read a requirement record and its criticality.
- Write a requirement that a test can decide, and recognise ones that cannot be tested.
- Use the traceability matrix to find untested behaviour.
- Add a site-specific requirement, a test case and its trace, step by step.
Prerequisites: 42.2 The lifecycle.
A requirement is a sentence that a test can make true or false. The package keeps them in one controlled file, requirements.csv, with five columns: id, area, requirement, reference (the documentation section the statement comes from) and criticality.
id,area,requirement,reference,criticality
URS-GEN-004,General,"The program shall not write into an existing non-empty output folder unless --overwrite is given, and shall leave the existing files untouched when it refuses.",COMMANDS.md §8,High
There are 90 of them, in 23 areas. The figure above shows how they are spread: the estimation command (FIT, 14), general behaviour (GEN, 11) and data integrity (DI, 10) carry the most, which matches where silent errors would hurt.
| Criticality | Count | Meaning in the plan |
|---|---|---|
| High | 45 | Every test of a High requirement must pass for acceptance |
| Medium | 31 | Must pass, or each failure needs a documented deviation with a risk assessment |
| Low | 14 | As Medium |
What makes a requirement testable
Compare two statements about the same behaviour.
| Weak | Testable |
|---|---|
| "The program should handle bad input sensibly." | "Each class of failure shall end with its documented exit code and an explanatory message with a hint; no failure shall end silently or with exit code 0." (URS-GEN-003) |
| "Results should be reproducible." | "Same inputs, settings and seed shall give identical result files; the numerical results shall not depend on the number of worker threads." (URS-DI-004, URS-DI-005) |
| "Output must be traceable." | "Every command shall list the SHA-256 of every file it wrote, and the list shall verify." (URS-DI-002) |
Four rules explain the difference.
- One observable per sentence. "Identifies itself and rejects bad input" is two requirements; a single test result cannot cover both.
- A decision procedure. "Sensibly" has none. An exit code, a file, a number within a tolerance and a refusal each do.
- A source. The
referencecolumn ties the statement to the documentation, so that a failing test points to either a defect or an out-of-date document—both worth knowing. - A criticality that follows consequence, not effort. The estimation objective is High because a wrong value is silent; the help text is Low because a wrong value is obvious.
From requirement to test: the trace
build_rtm.py writes RTM.md, a table with one row per requirement and the tests that verify it:
| Requirement | Area | Criticality | Verified by |
|---|---|---|---|
| URS-GEN-004 | General | High | DI-004 |
| URS-GEN-005 | General | High | OQ-QCN-002, PQ-001, DI-005 |
| URS-GEN-003 | General | High | OQ-GEN-002, OQ-GEN-003, OQ-ASK-003, OQ-FIT-010, OQ-INS-005, OQ-QCD-003, OQ-QCN-002, OQ-SIM-005 |
Read it two ways. Forward: for a requirement, which tests prove it? URS-GEN-003 (every failure has an exit code and a hint) is verified by eight tests spread over six commands, because failure handling is a property of the whole program. Backward: for a test, which requirement does it defend? A test with no requirement is either an orphan to delete or a missing requirement to write; the generator exposes both.
Worked example: adding a site requirement
Suppose your standard operating procedure says that no analysis data set may reach a fit while it still has an error-level finding, and your pipeline script enforces this by running qc-data --fail-on error first and stopping on a non-zero exit. The package already tests the command (OQ-QCD-001 to OQ-QCD-004), but your procedure depends on one specific behaviour—the exit code—on your own data conventions. Here is how to bring that into the validated state.
Step 1 — state it as a requirement.
URS-SITE-001,Site,"With --fail-on error, qc-data shall end with a non-zero exit code when the data set contains an error-level finding and with exit code 0 when it contains none.",SOP-DA-07 §3,High
Step 2 — choose fixtures with known answers. The package ships a data set with twelve seeded defects (qc_dirty.csv, one per individual) and a clean one (the reference population). Because the defects were seeded by script, the expected finding for each individual is known independently of the program. Add your own site-specific data set only if your conventions create cases those do not.
Step 3 — write the test case by copying an existing one and filling the same fields the package uses:
{"id": "OQ-SITE-001", "title": "SOP-DA-07 gate: qc-data --fail-on error",
"requirements": ["URS-SITE-001"], "risk": "High",
"objective": "A dirty data set stops the pipeline; a clean one does not.",
"expected": "Exit 7 for the dirty data set, exit 0 for the clean one, checksums verify for both.",
"steps": [{"copy": "{data}/qc_dirty.csv", "to": "."},
{"copy": "{data}/pop_oral1.csv", "to": "."},
{"nlmx": ["qc-data", "qc_dirty.csv", "--fail-on", "error", "-o", "{work}/dirty"], "expect_exit": 7},
{"nlmx": ["qc-data", "pop_oral1.csv", "--fail-on", "error", "-o", "{work}/clean"], "expect_exit": 0}],
"checks": [{"type": "checksums_verify", "dir": "dirty"},
{"type": "checksums_verify", "dir": "clean"}]}
Step 4 — regenerate and re-seal. build_rtm.py (which refuses to finish if URS-SITE-001 had no test), build_protocols.py, then seal_package.py --seal under change control.
The same four steps work for any site rule: a naming convention, a reporting constraint, a unit-conversion step in your own scripts. Page 42.17 collects them as the extension procedure.
Requirements that cannot be tested
Some statements belong in the plan, not the URS, because no test can decide them:
- "The program shall give correct results." (Untestable in general; the testable form is a list of specific computations with specific references.)
- "Users shall be trained." (Procedural; it belongs in
roles_and_training.md.) - "The assistant's answers shall be scientifically sound." The package refuses this one on purpose: the assistant's guardrails (forbidden commands, path policy, session record) are tested; the quality of a real model's prose is judged by a human in a manual test and is outside software validation.
Review checklist
- Does every requirement describe one observable and name its decision procedure?
- Is each requirement traced to at least one test, and each test to at least one requirement?
- Are site-specific requirements in the same controlled file, not in a side document?
- Does criticality follow the cost of a silent error?
Navigation
See the previous page, the next page and the complete validation reference.