Skip to content

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

TestPlan Structure

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

{
  "resourceType": "TestPlan"
}

Status

{
  "status": "draft" | "active" | "retired"
}

Name

{
  "name": "PatientTestSuite"
}

Optional Elements

URL

Canonical identifier:

{
  "url": "http://hl7.org.au/fhir/core/TestPlan/au-core-patient"
}

Version

{
  "version": "1.0.0"
}

Title

Human-readable title:

{
  "title": "AU Core Patient Test Suite"
}

Description

{
  "description": "Comprehensive test suite for AU Core Patient profile"
}

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 testing
  • integration - Integration testing
  • production - 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 pass
  • optional - Should pass
  • strict - 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).

  1. Use sequences for ordered execution
  2. Document dependencies explicitly
  3. Provide clear narratives for each test run
  4. Version your TestPlans alongside IGs
  5. Test TestPlans before production use

Next Steps