TestScript — Executable FHIR integration test suite
The formal format for executable FHIR integration tests. Driven by HL7 Connectathons, consumed by Touchstone and Aegis Test Platform: every vendor runs the same suite.
Purpose of the resource
TestScript describes an integration-test suite that a test engine can execute against a FHIR server. Each test contains operations (HTTP GET/POST/PUT/DELETE, $-prefixed operation calls, transaction Bundles) and assertions (status code, content type, response body, HTTP header, FHIRPath value in the resource).
Key fields
| Field | Type | Cardinality | Role |
|---|---|---|---|
url | uri | 1..1 | Canonical URL. |
identifier | Identifier[] | 0..* | Business identifiers. |
version | string | 0..1 | Version. |
name | string | 1..1 | Technical name. |
title | string | 0..1 | Title. |
status | code | 1..1 | draft | active | retired | unknown. |
origin | BackboneElement[] | 0..* | Originating actors. |
destination | BackboneElement[] | 0..* | Target actors. |
metadata | BackboneElement | 0..1 | FHIR prerequisites (CapabilityStatement, IG). |
scope | BackboneElement[] | 0..* | Scope under test. |
fixture | BackboneElement[] | 0..* | Resources preloaded for the test. |
profile | canonical[] | 0..* | Profiles used in fixtures. |
variable | BackboneElement[] | 0..* | Reusable variables. |
setup | BackboneElement | 0..1 | Setup actions. |
test | BackboneElement[] | 0..* | Executable tests. |
teardown | BackboneElement | 0..1 | Teardown. |
JSON example
{
"resourceType": "TestScript",
"id": "example-patient-read",
"url": "http://example.org/TestScript/patient-read",
"version": "5.0.0",
"name": "PatientReadTest",
"title": "Patient Read Test",
"status": "active",
"experimental": false,
"date": "2026-05-15",
"test": [{
"name": "Read Patient",
"action": [{
"operation": {
"type": {
"system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
"code": "read"
},
"resource": "Patient",
"encodeRequestUrl": true,
"params": "/Patient/example"
}
}, {
"assert": {
"description": "Confirm 200 OK",
"response": "okay"
}
}]
}]
} Touchstone and Connectathons
- Touchstone — FHIR test platform operated by Aegis, used as the official engine of HL7 Connectathons.
- Cardea — open-source tool used for ONC FHIR certification.
- HAPI Test Suite — JVM runner integrated in the HAPI FHIR base.
- IGs publish their TestScripts alongside their StructureDefinitions and ExampleScenarios.
Common pitfalls
- Assert without
operator— default equals, rarely what you want for dates or IDs. - Uninitialised variable — the test fails before the assertion.
- No teardown — the next run starts in a polluted state.