42.9 Operational qualification and the anatomy of a test
What you will learn
- Read a
testcases.jsonentry field by field, and a check line by line.- List the check types and comparison keys, and choose the right one.
- See how the 96 operational tests are spread, and why
fithas the most.- Annotate one real test (OQ-FIT-001) as a model for your own.
Prerequisites: 42.5 Sources of truth and 42.6 Tolerance policy.
Operational qualification (OQ) asks the central question: does every command do what its documentation says, tested against values that did not come from the program? The package has 96 OQ tests in 20 areas—one folder per command or feature—each with its own README, a generated PROTOCOL.md for paper execution, and the machine-readable testcases.json.
Anatomy of a test case
{"section": "OQ-X", "title": "…", "description": "…", "tests": [
{"id": "OQ-X-001", "title": "…", "requirements": ["URS-…"], "risk": "High",
"objective": "…", "acceptance": "…", "expected": "…",
"steps": [ {"copy": "{data}/file.csv", "to": "."},
{"nlmx": ["fit", "m.ctl", "-o", "{work}/out"], "expect_exit": 0, "name": "…"},
{"exec": ["{python}", "{tools}/verify_forest.py", "out", "…"]},
{"write": "settings.txt", "text": "…"} ],
"checks": [ {"type": "ext_value", "file": "out/m.ext", "column": "THETA1",
"approx": 4.0, "rel_tol": 0.1, "desc": "…"} ] } ] }
| Field | Purpose |
|---|---|
id, title |
Stable identifier and one-line statement |
requirements |
The URS identifiers this test verifies (the trace) |
risk |
High, Medium or Low: the test depth class from the risk register |
objective, acceptance, expected |
Prose for the paper protocol: what is tested, how to judge, what a pass looks like |
steps |
The actions: copy a fixture, run a command with an expected exit code, run an independent calculator, write a small file |
checks |
The judgements: automatic comparisons of produced files with expected values and tolerances |
Placeholders keep the steps portable: {work} the test's own folder, {data} the package data folder, {tools} the calculators, {nlmx} the executable, {python} the interpreter, {nlmx_version}, and {exp:path} a value drawn from expected_values.json. The last one is how a check says the expected value is the independent one, not a number typed into the test.
Check types
| Group | Types |
|---|---|
| Exit and text | exit_code, stdout_contains, stdout_regex, stdout_not_contains, stdout_not_regex |
| Files | file_exists, file_absent, file_nonempty, glob_exists, file_contains, file_regex, file_not_contains, glob_regex, file_starts_with, zip_contains |
| Tables | csv_columns, csv_rows, csv_value, csv_column_stat, csv_close, ext_value, json_value |
| Integrity | checksums_verify, files_identical, dirs_identical |
| Other | manual |
Comparison keys: equals, approx with rel_tol or abs_tol, min / max, regex. Any check can carry "negate": true—the check must not hold. Negation is what makes tamper detection testable: a checksum verification after a one-bit change must fail, and the test passes only if it does.
Annotating a real test: OQ-FIT-001
The test fits the reference population with FOCE-I and checks that the estimates recover the generating values.
| Element | Content |
|---|---|
| Objective | The estimates recover the values that generated the data within statistical error (SE of CL 3 %, V 2.4 %, K_A 1.3 %); the weight effect is deliberately not modelled so the variances are inflated |
| Steps | stage pop_oral1.*; run fit pop_oral1.ctl -o {work}/fit |
| Check 1 | checksums_verify on the output folder: every file the command listed verifies |
| Check 2 | fit_summary.txt contains MINIMIZATION SUCCESSFUL |
| Checks 3–5 | ext_value: THETA1 ≈ 4.0, THETA2 ≈ 40.0, THETA3 ≈ 1.2, each within 10 % relative; the descriptions say why ("typical clearance within 10 % of the true 4.0 L/h") |
| Check 6 | SIGMA(1,1) ≈ 0.0225 within 0.004 absolute |
| Checks 7–8 | OMEGA(1,1) between 0.08 and 0.20, OMEGA(2,2) between 0.03 and 0.12: bands wider than the truth (0.09, 0.04) because the unmodelled weight effect inflates the variances |
Four design choices deserve attention. The checksum check comes first, so a truncated or altered output cannot reach the numerical comparison. The text check confirms the optimiser converged before any estimate is trusted. Each tolerance has a stated reason in its description (page 42.6). And the variance checks use bands, not points, because the test author knows the true value is deliberately inflated; a point comparison would encode an untrue expectation.
Coverage by area
The distribution in the figure follows the risk register. The fit command carries 14 tests because the objective function, the predictions, the solvers, the covariate parameterisation, tied variances, integer event items, closed-form standard errors, batch fitting and unused parameters each have a High-risk hazard (RK-01 to RK-04, RK-32, RK-33). The remaining areas:
| Area | Tests | What it proves, in one line |
|---|---|---|
| general | 9 | help, usage errors, exit codes and hints, settings templates, logging, schema |
| er | 8 | Emax, logistic, Poisson, Cox, ordinal and longitudinal models against independent fits |
| nca | 7 | IV and oral closed forms, trapezoid rules, partial AUC, flat and extreme-scale profiles |
| generate | 6 | project structure, bounds, re-fit reproduces the stated OFV, ODE equals analytic |
| ask, cov, inspect/validate, power, sims | 5 each | guardrails; frozen/scm/posterior engines; reconciliation and verdicts; Wald power and FIM; exposure closed forms and summary statistics |
| qc-data, qc-nm, vpc | 4 each | seeded defects, safe corrections, observed bin statistics |
| custom, eda, report | 3 each | tables, plots, documents |
| autoinit, forest | 2 each | initial estimates near truth; ratios equal the model at stated values |
| screen, simulate-study | 1 each | recommended structure; result tables |
Every one of the program's commands has at least one operational test.
Writing a good OQ test
- Start from the hazard, not the feature. Ask "how could this silently go wrong?" and write the test that would notice.
- Name the reference in the objective. "Compared with an independent marginal likelihood by trapezoid quadrature" is a reference; "compared with a known good value" is not.
- Check the record first, the number second.
checksums_verifybeforeext_value. - Make the failure message teach. The
descfield is what a tester reads in a failing record. - Test the refusal too. For every behaviour, ask what the program should do with the wrong input (page 42.14).
Review checklist
- Does every test name a requirement and a risk class?
- Is each expected value an
{exp:…}reference, an independent calculator, or a stated truth? - Does every check carry a
descthat explains the tolerance? - For every positive test, is there a negative one?
Navigation
See the previous page, the next page and the complete validation reference.