TestPlan Basics¶
Organise multiple TestScripts into an ordered test suite.
Prerequisites¶
- Your First TestScript completed
Why a TestPlan?¶
A TestPlan lets you: - Group related TestScripts into a named suite - Express execution order (create before read, read before delete) - Run the whole suite with a single command
Step 1: Create the TestScripts¶
Create three minimal TestScripts in src/test/resources/fhir/:
patient-create.tsh
TestScript: PatientCreate
Status: #draft
Fixture: patient from "fixtures/patient.json"
Setup:
* operation create Patient from patient as created
* assert response = created
* variable patientId = Patient.id from created
patient-search.tsh
TestScript: PatientSearch
Status: #draft
Test: "Search by family name"
* operation search Patient ?family=Smith as searchResponse
* assert response = okay
* assert Bundle.total > 0
patient-delete.tsh
TestScript: PatientDelete
Status: #draft
Teardown:
* operation delete Patient/${patientId}
* assert response = noContent
Step 2: Create the TestPlan¶
Create src/test/resources/fhir/patient-suite.tph:
TestPlan: PatientSuite
Title: "Patient API Test Suite"
Status: #active
TestCase: Create
TestRun: TestScript/patient-create
TestCase: Search
Dependency: Create
TestRun: TestScript/patient-search
TestCase: Delete
Dependency: Search
TestRun: TestScript/patient-delete
The Dependency lines ensure Create runs before Search, and Search before Delete.
Step 3: Run the TestPlan¶
@ExtendWith(FhirFrogExtension.class)
class PatientSuiteTest {
@FhirTestConfig(serverUrl = "http://localhost:8080/fhir",
fixtureBasePath = "src/test/resources/fhir")
@TestFactory
Stream<DynamicNode> patientSuite(FhirTestConfig config) {
return new TestPlanProvider(config).provide("fhir/patient-suite.tph");
}
}
JUnit expands the TestPlan into individual DynamicTest entries, one per TestCase,
executed in dependency order.
Step 4: Understand the Output¶
Next Steps¶
- TestPlan Structure — Full TestPlan reference
- Dependencies — Complex dependency graphs
- TPH Syntax — Full shorthand reference
- Testcontainers Setup — Automated server setup