Testing¶
Bogus for shape, Synthea for clinical truth¶
NUnit is the .NET test framework. Fixture parallelism is capped at two workers; process-environment fixtures are nonparallel. Moq provides plain dependency stubs. AutoFixture creates nonclinical settings, request DTOs and administrative rows; seeded Bogus generates synthetic identifiers and display text. Random values never enter A1c, blood-pressure, ASCVD or clinical-risk expectations. Clinical integration and parity tests use the captured Synthea cohort and the explicitly labelled synthetic Ottehr samples; deterministic boundary tests retain their documented clinical inputs.
NonClinicalDataTests exercises malformed request rejection before any unit-of-work access, then SQLite round trips for cursor, staging crosswalk and outbox metadata. The staging row links resource type/FHIR ID/version/source; no additional reconciliation crosswalk is invented before pass 9.
EhrTransportTests uses strict Moq HttpMessageHandler mocks, including protected SendAsync, and asserts actual call counts. No Oystehr network calls are made. Existing concrete SQLite contexts remain integration fixtures, not mocks of EF query behavior. No handwritten ISourceSettings or IUnitOfWork stub remains.
Retained behavioral test doubles:
PipelineTests.MemorySource/OttehrIntakeTests.MemorySource: filter synthetic streams by resource type and honor cancellation while enumerating.SourceSafetyTests.TestSource: models fixed read bounds, source identity, cancellable enumeration and prohibited-read accounting.SyncBatchSafetyTests.CursorSource: applies cursor windows and counts rereads of failed versions.SyncBatchSafetyTests.BatchSource: emits only the requested resource batch and observes cancellation.TelemetrySecurityTests.CaptureProcessor: captures emitted telemetry for the redaction boundary assertions.ApiSecurityTests.TestHost: starts the real HTTP pipeline and real SQLite store, owns their lifetime and signs synthetic test tokens.EhrTransportTests.Env: restores process environment variables on disposal; both environment-mutating fixtures are[NonParallelizable].
NUnit conversion receipts¶
Before conversion:
dotnet test tests/FhirDemo.Tests --logger "trx;LogFileName=baseline.trx" --results-directory .artifacts/pass11
Passed! - Failed: 0, Passed: 267, Skipped: 0, Total: 267, Duration: 13 s - FhirDemo.Tests.dll (net10.0)
dotnet test tests/FhirDemo.AppHost.Tests --logger "trx;LogFileName=baseline-apphost.trx" --results-directory .artifacts/pass11
Passed! - Failed: 0, Passed: 4, Skipped: 0, Total: 4, Duration: 609 ms - FhirDemo.AppHost.Tests.dll (net10.0)
Each original test file is converted in its own commit. The full solution suite was invoked after each file; the adapter audit below identifies three runs that used stale assemblies and must not be treated as conversion evidence. Both adapters were temporarily required during the incremental conversion; the completed tree removes xUnit packages and attributes entirely. Baseline total: 271.
The Windows application-control policy blocked newly built test assemblies after the first three successful conversions:
System.IO.FileLoadException: Could not load file or assembly 'C:\Users\fives\source\repos\fhir-pipeline-demo-wt-WT-dc65\tests\FhirDemo.Tests\bin\Debug\net10.0\FhirDemo.Tests.dll'. An Application Control policy has blocked this file. (0x800711C7)
No security policy was changed. Subsequent full-suite receipts use the standard Linux .NET 10 SDK container (the same OS family as CI), with separate build artifacts inside the repository so fixture-root discovery works:
docker exec fhir-pass11-nunit dotnet test \
--artifacts-path /work/.artifacts/pass11/linux \
--logger "trx;LogFilePrefix=nunit-<file>" \
--results-directory /work/.artifacts/pass11
Individual logs and TRX results are retained in .artifacts/pass11/; the committed receipt table below records the checks used for each conversion.
Correction: stale prepared-file timestamps¶
Copy-Item preserved the timestamps of three prepared conversion files. MSBuild reused an older test assembly, so the following earlier runs passed with the xUnit executor and do not prove those conversions:
| File | Commit with stale receipt | Cases in stale run |
|---|---|---|
| ApiSecurityTests | 4482c45 |
32 |
| SourceSafetyTests | 1220c32 |
6 |
| EhrTransportTests | 07d93c3 |
27 |
The initial, uncommitted EnvironmentIsolation run was stale too. PipelineTests 6545230 and the first 22 conversions were verified with the NUnit executor. No history was rewritten. Source files were rewritten with current timestamps, then the whole solution was forcibly rebuilt and retested:
docker exec fhir-pass11-nunit dotnet build --no-incremental --artifacts-path /work/.artifacts/pass11/linux
docker exec fhir-pass11-nunit dotnet test --no-build --artifacts-path /work/.artifacts/pass11/linux --logger "trx;LogFilePrefix=nunit-prepared-rebuild" --results-directory /work/.artifacts/pass11
The fresh main TRX (nunit-prepared-rebuild_net10.0_20261113033606.trx) contains 268 NUnit cases and zero xUnit cases. Fresh affected-fixture counts: API 32, Pipeline 20, SourceSafety 6, Moq transport 27, EnvironmentIsolation 2. The fresh full-suite result accompanies EnvironmentIsolation commit 2a3e4d4 and supersedes those stale receipts:
Passed! - Failed: 0, Passed: 4, Skipped: 0, Total: 4, Duration: 280 ms - FhirDemo.AppHost.Tests.dll (net10.0)
Passed! - Failed: 0, Passed: 268, Skipped: 0, Total: 268, Duration: 52 s - FhirDemo.Tests.dll (net10.0)
Completed NUnit stack¶
Before: 267 main + 4 AppHost = 271. After: 270 main + 4 AppHost = 274, zero failures or skipped tests. The three added cases are the second environment-isolation case and two nonclinical data tests. All final TRX test definitions use the NUnit executor. No xUnit package or source reference remains in the test projects.
Passed! - Failed: 0, Passed: 4, Skipped: 0, Total: 4, Duration: 255 ms - FhirDemo.AppHost.Tests.dll (net10.0)
Passed! - Failed: 0, Passed: 270, Skipped: 0, Total: 270, Duration: 33 s - FhirDemo.Tests.dll (net10.0)
Run the complete solution locally with dotnet test. The Linux verification used docker exec fhir-pass11-nunit dotnet test --artifacts-path /work/.artifacts/pass11/linux --logger "trx;LogFilePrefix=nunit-final" --results-directory /work/.artifacts/pass11.
| Converted file | Commit | Recorded full-suite pass count | Evidence |
|---|---|---|---|
| BronzeIdempotencyTests.cs | e260e4e |
271 | NUnit adapter confirmed |
| ClinicalDisplayTests.cs | 275a9cc |
271 | NUnit adapter confirmed |
| ClinicalEligibilityTests.cs | a3be498 |
271 | NUnit adapter confirmed |
| EhrAppHostTests.cs | 0e67092 |
271 | NUnit adapter confirmed |
| FhirStatusTests.cs | bfe7326 |
271 | NUnit adapter confirmed |
| FixtureProfileTests.cs | f1f17d0 |
271 | NUnit adapter confirmed |
| FixtureRiskParityTests.cs | c3d225a |
271 | NUnit adapter confirmed |
| FixtureSourceCacheTests.cs | 771e5aa |
271 | NUnit adapter confirmed |
| LakehouseBloodPressureTests.cs | 4407ac4 |
271 | NUnit adapter confirmed |
| LakehouseReplayTests.cs | 1654388 |
271 | NUnit adapter confirmed |
| NeverImputeTests.cs | 788fe6f |
271 | NUnit adapter confirmed |
| OttehrIntakeTests.cs | cafeeb1 |
271 | NUnit adapter confirmed |
| OttehrProvenanceTests.cs | 2343a88 |
271 | NUnit adapter confirmed |
| Pass7LakehouseParityTests.cs | 884981d |
271 | NUnit adapter confirmed |
| Pass7SummaryTests.cs | 534d446 |
271 | NUnit adapter confirmed |
| ReportTests.cs | ab1a8fc |
271 | NUnit adapter confirmed |
| RiskTests.cs | 5ab2541 |
271 | NUnit adapter confirmed |
| SmokingEvidenceTests.cs | ab7bfaa |
271 | NUnit adapter confirmed |
| StatusLiteralTests.cs | 929db7d |
271 | NUnit adapter confirmed |
| SyncBatchSafetyTests.cs | 4dea54f |
271 | NUnit adapter confirmed |
| TelemetrySecurityTests.cs | a57ee61 |
271 | NUnit adapter confirmed |
| VerificationStatusMigrationTests.cs | 66b9b71 |
271 | NUnit adapter confirmed |
| ApiSecurityTests.cs | 4482c45 |
271 | STALE xUnit run; superseded by the clean NUnit rebuild above |
| PipelineTests.cs | 6545230 |
271 | NUnit adapter confirmed |
| SourceSafetyTests.cs | 1220c32 |
271 | STALE xUnit run; superseded by the clean NUnit rebuild above |
| EhrTransportTests.cs | 07d93c3 |
271 | STALE xUnit run; superseded by the clean NUnit rebuild above |
| EnvironmentIsolationTests.cs | 2a3e4d4 |
272 | NUnit adapter confirmed |
| AppHostModelTests.cs | 3f759bd |
272 | NUnit adapter confirmed |
Analyzer and style verification¶
Tests use invariant-culture fixture parsing and ordinal string comparisons, reuse immutable expected arrays, retain explicit type/null assertions, and use the Async suffix for asynchronous test and helper methods. No diagnostic suppression was added to tests. The final clean build treats recommended analyzer warnings as errors:
docker exec fhir-pass11-nunit dotnet build --no-incremental --artifacts-path /work/.artifacts/pass11/linux -p:AnalysisLevel=latest-recommended -warnaserror
docker exec fhir-pass11-nunit dotnet test --no-build --artifacts-path /work/.artifacts/pass11/linux --logger "trx;LogFilePrefix=nunit-analyzers" --results-directory /work/.artifacts/pass11
Build succeeded.
0 Warning(s)
0 Error(s)
Passed! - Failed: 0, Passed: 4, Skipped: 0, Total: 4, Duration: 228 ms - FhirDemo.AppHost.Tests.dll (net10.0)
Passed! - Failed: 0, Passed: 270, Skipped: 0, Total: 270, Duration: 34 s - FhirDemo.Tests.dll (net10.0)
nunit-analyzers_net10.0_20261113034531.trx, nunit-analyzers_net10.0_20261113034607.trx) report 4/4 and 270/270 cases respectively, all executor://nunit3testexecutor/.
Way 2 mutation evidence¶
Way 2 uses the same clinical evidence rule: Bogus for shape, Synthea for clinical truth. Clinical cohort records are the captured Synthea and upstream synthetic Ottehr fixtures. Fixed analytical boundary scenarios test math and threshold behavior; they are not patient records and use no random clinical values. TypeScript is retained for the Ottehr Zambda runtime; the npm-native mutation wrapper uses Node so the Way 2 gate can run independently in its runtime.
cd ehr-track/risk; npm ci; npm test; npm run mutation runs Vitest and StrykerJS. Scope is all of rules.ts; positive break 94.03 is the measured 99.03 baseline minus five. A prehook removes any old report, so zero-mutant runs cannot reuse stale success. The verifier rejects empty, unassessed, unfinished, errored, unknown-status and below-threshold reports. A negative test proves these conditions fail. Report location: ehr-track/risk/reports/mutation/mutation.json.
Way 2 surviving and uncovered mutants¶
No RiskEngine-equivalent survivor is silently waived. These are the complete final report entries (source unchanged at rules.ts, StrykerJS 10.1.1):
| ID | Status/location | Mutation | Equivalence evidence |
|---|---|---|---|
| 22 | Survived, line 20 cols 69–90 | Replace typeof n === 'number' with true |
Remaining Number.isFinite(n) already rejects every non-number without coercion; n > 0 retains positivity. Tests cover null, undefined, NaN, infinities, zero, negative, positive, and a string passed through the runtime boundary. Identical predicate for all JS values. |
| 385 | Survived, line 82 cols 16–33 | Replace ascvd.score != null with true before && ascvd.score >= 20 |
calculateAscvd returns only number or null. JavaScript evaluates null >= 20 as false, so deleting this guard cannot change the indicator. Both missing and present/high scores have full-output contracts. |
| 388 | Survived, line 82 cols 35–50 | ascvd.score >= 20 becomes ascvd.score > 20 |
Score is 100 * (1 - p), with positive Math.pow result p in [0,1]. At the only boundary, adjacent representable doubles p=0.8 and p=0.7999999999999999 yield 19.999999999999996 and 20.000000000000007. No representable intermediate p exists, so score cannot equal exactly 20. A test pins these neighboring outputs; low/high full-output contracts cover both indicators. |
| 62 | NoCoverage, line 32 cols 80–82 | Change private day null fallback '' to "Stryker was here!" |
Unreachable branch: its only callers are normalized valid asOf and lab/BP facts already admitted by datedBefore, which rejects null/invalid timestamps. The helper is private. Contracts exercise all reachable call sites; tests reject invalid dates and incomplete records. Count remains honestly reported as no-coverage, with no ignore directive. |
Node 22.23.5 (the deployed runtime) and Node 24.18.0 each pass all 64 risk tests. Raw captured ASCVD scores allow an absolute 1e-10 difference for runtime floating-point rounding; captures, missing inputs, descriptions, indicators, flags and cards retain exact comparisons. A fresh StrykerJS run after this change retained the same 412 mutants, 99.03% score and the same three equivalent survivor IDs. The separate viewer has six browser tests and a zero-vulnerability npm audit.
.NET mutation gates¶
Run dotnet tool restore, then bash .github/scripts/pass11-mutation.sh <lane> with core, operational, lakehouse, provider, or way2; omit the lane to run all five. Stryker.NET 5.1.0 is pinned in the tool manifest. All .NET mutate globs are project-relative. Core includes RiskEngine, ClinicalMapping (FHIR-to-entity mapping) and FhirStatus; operational includes SyncService skip/upsert and IntakeMapping; lakehouse includes the complete transform runner; provider includes query translation, SQL generation, type mapping, raw commands and migration SQL generation. Pass-9 reconciliation must be added when implemented.
Each run gets a fresh output directory. The C# report guard rejects zero assessed mutants, unknown/incomplete statuses, nonfinite/nonpositive thresholds and scores below the threshold. Compile-error and ignored mutants are disclosed separately and never counted as killed. Integer .NET thresholds are floor(measured baseline) - 5, never zero. CI runs the five lanes independently, with no fail-fast cancellation of sibling lanes.
| Lane | Total | Killed | Survived | Timeout | No coverage | Compile error | Ignored | Score | Break |
|---|---|---|---|---|---|---|---|---|---|
| Core | 573 | 471 | 38 | 12 | 14 | 21 | 17 | 90.28% | 85 |
| Operational | 195 | 113 | 34 | 0 | 3 | 28 | 17 | 75.33% | 70 |
| Lakehouse | 119 | 94 | 4 | 0 | 6 | 4 | 11 | 90.38% | 85 |
| Provider | 774 | 376 | 173 | 2 | 61 | 116 | 46 | 61.76% | 56 |
An early operational run excluded all of RunAsync because mutation broke definite assignment. It was discarded as insufficient even though its numeric score passed. Initializing the two locals before normal guarded assignments restored mutation of skip/upsert; the final report above includes it. The same type-mapping initialization restored 30 provider mutants. These changes preserve ordinary execution; they do not exclude difficult source from mutation.
The authoritative Core command, from src/FhirDemo.Core, was dotnet stryker -f ../../stryker-config.json --output /output/mutation --skip-version-check --concurrency 24. It finished in 00:27:37.0689105, exit 0, using all 270 main NUnit tests and 65 gold/risk contracts. QualityGate mutation /output/mutation/reports/mutation-report.json 85 independently reports PASS. Break 85 is floor(90.28) - 5. The completed report's three mutated sources exactly match current files; all 36 C# source/project files across both test projects match the run's container by SHA256. The authoritative report is .artifacts/pass11/core-final-linux/mutation/reports/mutation-report.json.
All 12 Core timeouts are in ClinicalMapping and retain Timeout status. Even counting none as detections yields 471 / 535 = 88.04%, above break 85. The local run's 24-worker warning is retained; CI uses two workers. No OOM or OOM kill was observed. Ignored/compile-error mutants are disclosed, not counted as killed.
Every surviving .NET RiskEngine mutant¶
A focused diagnostic run using the unchanged RiskTests and captured RiskCaptureContractTests found ten real gaps. Four new deterministic RiskBoundaryTests cases kill all ten. Both the follow-up diagnostic and the final full Core report confirm RiskEngine total=323, killed=308, survived=1, timeout=0, no-coverage=0, excluded=14, score=99.68% (seven compile errors, seven ignored). The full Core source-scope measurement above is the gate; the focused diagnostic is supplemental evidence.
| Mutant IDs | Original survival | Final proof |
|---|---|---|
| 668, 742, 783, 842 | <= asOf changed to < asOf |
Killed by EvidenceExactlyAtAsOfRemainsEligible: A1c, complete BP, ASCVD systolic and lipids exactly at the clock remain eligible. |
| 735, 777, 831 | Ascending ordinal tie order changed to descending | Killed by EqualDatesUseAscendingOrdinalIdsForBloodPressureAndLipids: equal timestamps, mixed-case IDs and explicit source ordering. |
| 849, 863, 869 | Missing age/sex/race labels erased | Killed by MissingDemographicsPreserveActionableInputNames: exact missing-input list and detail. |
| 796, RiskEngine.cs line 56 | ascvd.Score >= 20 changed to ascvd.Score > 20 |
Equivalent for every attainable binary64 PCE result, as proved below. |
The score is 100 * (1 - p), where p is the double returned by Math.Pow(survival, Math.Exp(sum - mean)), in [0,1]. At p=0.8, the result is 19.999999999999996; at its immediate predecessor Math.BitDecrement(0.8)=0.7999999999999999, it is 20.000000000000007. No representable p lies between them. Monotonic subtraction and multiplication cannot produce exactly 20, so >= 20 and > 20 agree for every reachable score; null also changes neither branch. PceFloatingPointScoreCannotEqualTwenty checks both adjacent doubles and exact results without tolerance. No ignore directive hides this survivor.
Full and diagnostic JSON receipts live under .artifacts/pass11/; VERIFY distinguishes completed runs from a superseded pre-boundary run that was canceled to free resources. No canceled or empty report is a passing gate.