TestPlan Structure¶
Detailed structure and elements of FHIR TestPlan resources.
R5 Resource
TestPlan is an R5 resource that's still evolving. Structure may change in future FHIR versions.
Resource Model¶
Basic Structure¶
{
"resourceType": "TestPlan",
"id": "example",
"url": "http://example.org/TestPlan/example",
"name": "ExampleTestPlan",
"title": "Example Test Plan",
"status": "active",
"testScope": [],
"testObjective": [],
"testCase": []
}
Required Elements¶
Resource Type¶
Status¶
Name¶
Optional Elements¶
URL¶
Canonical identifier:
Version¶
Title¶
Human-readable title:
Description¶
Test Scope¶
Define what's being tested:
{
"testScope": [
{
"reference": "http://hl7.org.au/fhir/core/StructureDefinition/au-core-patient",
"type": {
"coding": [{
"system": "http://hl7.org/fhir/testscript-scope-phase-codes",
"code": "unit"
}]
}
}
]
}
Scope Types¶
unit- Unit testingintegration- Integration testingproduction- Production validation
Test Objectives¶
Document test goals:
{
"testObjective": [
{
"description": "Verify Patient profile conformance",
"type": {
"coding": [{
"system": "http://hl7.org/fhir/testscript-scope-conformance-codes",
"code": "required"
}]
}
}
]
}
Conformance Types¶
required- Must passoptional- Should passstrict- Strict conformance
Test Cases¶
Simple Test Case¶
{
"testCase": [
{
"sequence": 1,
"testRun": [
{
"narrative": "Create and read patient",
"script": {
"reference": "TestScript/patient-crud"
}
}
]
}
]
}
With Dependencies¶
{
"testCase": [
{
"sequence": 1,
"testRun": [
{
"narrative": "Setup test data",
"script": {
"reference": "TestScript/setup"
}
}
]
},
{
"sequence": 2,
"dependency": [
{
"predecessor": "TestScript/setup"
}
],
"testRun": [
{
"narrative": "Run tests",
"script": {
"reference": "TestScript/tests"
}
}
]
}
]
}
Multiple Test Runs¶
{
"testCase": [
{
"testRun": [
{
"narrative": "Patient CRUD",
"script": {"reference": "TestScript/patient-crud"}
},
{
"narrative": "Practitioner CRUD",
"script": {"reference": "TestScript/practitioner-crud"}
},
{
"narrative": "Organization CRUD",
"script": {"reference": "TestScript/organization-crud"}
}
]
}
]
}
Nested TestPlans¶
Reference other TestPlans:
{
"testCase": [
{
"testRun": [
{
"narrative": "Patient test suite",
"script": {
"reference": "TestPlan/patient-suite"
}
},
{
"narrative": "Practitioner test suite",
"script": {
"reference": "TestPlan/practitioner-suite"
}
}
]
}
]
}
Complete Example¶
{
"resourceType": "TestPlan",
"id": "au-core-complete",
"url": "http://hl7.org.au/fhir/core/TestPlan/au-core-complete",
"version": "1.0.0",
"name": "AUCoreCompleteTestSuite",
"title": "AU Core Complete Test Suite",
"status": "active",
"description": "Comprehensive test suite for AU Core implementation",
"testScope": [
{
"reference": "http://hl7.org.au/fhir/core/ImplementationGuide/hl7.fhir.au.core",
"type": {
"coding": [{
"system": "http://hl7.org/fhir/testscript-scope-phase-codes",
"code": "integration"
}]
}
}
],
"testObjective": [
{
"description": "Verify AU Core profile conformance",
"type": {
"coding": [{
"system": "http://hl7.org/fhir/testscript-scope-conformance-codes",
"code": "required"
}]
}
}
],
"testCase": [
{
"sequence": 1,
"testRun": [
{
"narrative": "Patient CRUD with Medicare and IHI",
"script": {
"reference": "TestScript/au-core-patient-crud"
}
}
]
},
{
"sequence": 2,
"testRun": [
{
"narrative": "Practitioner CRUD with HPI-I",
"script": {
"reference": "TestScript/au-core-practitioner-crud"
}
}
]
},
{
"sequence": 3,
"dependency": [
{
"predecessor": "TestScript/au-core-patient-crud"
}
],
"testRun": [
{
"narrative": "Observation with transaction bundle",
"script": {
"reference": "TestScript/au-core-observation-crud"
}
}
]
}
]
}
Best Practices¶
Organize Logically
Group related tests together and use clear narratives.
Avoid Deep Nesting
Keep TestPlan hierarchy shallow (max 2-3 levels).
- Use sequences for ordered execution
- Document dependencies explicitly
- Provide clear narratives for each test run
- Version your TestPlans alongside IGs
- Test TestPlans before production use
Next Steps¶
- Dependencies - Managing test dependencies
- Expansion - How TestPlans expand to tests
- Overview - TestPlan basics