haste-testscript-runner
Runs FHIR TestScript resources against a FHIR server and produces a TestReport. It is the engine behind haste-health testscript run, which executes Haste Health's conformance suites (core resources, US Core, ONC (g)(10), access control, SQL on FHIR) in CI and feeds the conformance pages on the website. It is server-agnostic: anything reachable through a haste-fhir-client HTTP client can be tested.
What a run covers:
- Fixtures from
containedresources, plus the request and response fixtures an operation captures withrequestIdandresponseId. - Variables (
${name}) resolved with a FHIRPathexpressionagainst the fixturesourceIdnames, or from a response'sheaderField. A variable must resolve to a single value. - Operations:
read,vread,create,update,updateCreate,patch,delete,deleteCondSingle,deleteCondMultiple,search,history,batch,transaction,capabilitiesandconforms;$operationinvocations; and plain HTTP requests (an operation with aurland notype), which is how a script follows an asynchronous request's status URL. - Assertions on
responseCodeorresponse,headerField,contentType,resourcetype, and FHIRPathexpressions compared to avalueor tocompareToSourceIdwithcompareToSourceExpression, using the operatorsequals,notEquals,in,notIn,greaterThan,lessThan,empty,notEmpty,contains,notContainsandeval. - Index waiting: search indexing is asynchronous, so before a search, an operation or a conditional delete or update the runner can wait, up to
index_wait_timeout, for the script's latest writes to become visible.
The TestReport mirrors the script's setup, test and teardown actions with a pass or fail result and a message for each failed assertion.
Install
Usage
use ;
use ;
use ;
use ;
// The per-request context carries the headers an operation's `requestHeader` asks for.
;
let token = BearerToken;
let client = new;
let script: TestScript = from_slice?;
let report = run
.await?;
assert_eq!;
run returns TestScriptError when the script itself cannot be executed (a missing fixture, a malformed operation, a failed request). A failing assertion is not an error: the report comes back with result set to fail.
Command line
Runs every TestScript under the input paths in parallel against the active profile's server and writes a transaction Bundle of TestReports. --wait-between-operations-ms adds a fixed delay after each operation and --allow-failure <id> records a known failure without failing the run.
Links
- API reference
- Source
- Rust SDK overview
- Conformance overview and test coverage, the pages built from these reports
- CLI reference and the FHIR TestScript specification
- TypeScript equivalent: @haste-health/testscript-runner
Part of Haste Health, licensed under Apache-2.0.