JUnit Integration¶
FHIR Frog provides a JUnit 5 extension for executing FHIR TestScripts and TestPlans directly in your test suite.
Perfect for FHIR Tool Developers
JUnit integration is ideal for Java developers building FHIR IG tools, libraries, and frameworks. Seamlessly integrate FHIR conformance testing into your development workflow.
Testcontainers Support
FHIR Frog works seamlessly with Testcontainers for fully isolated integration tests with containerized FHIR servers.
Setup¶
Add dependency:
<dependency>
<groupId>org.fhirfrog</groupId>
<artifactId>fhir-frog-library</artifactId>
<version>${fhir-frog.version}</version>
<scope>test</scope>
</dependency>
Basic TestScript Execution¶
@ExtendWith(FhirFrogExtension.class)
@FhirServerUrl("http://localhost:8080/fhir")
class PatientTests {
@TestScript("classpath:fhir/patient-crud.json")
void testPatientCRUD() {
// Test automatically executed from TestScript
}
}
TestPlan Execution¶
@ExtendWith(FhirFrogExtension.class)
@FhirServerUrl("http://localhost:8080/fhir")
@TestPlan("TestPlan/au-core-suite")
class AUCoreTestSuite {
// Tests dynamically generated from TestPlan
}
Testcontainers Integration¶
@ExtendWith(FhirFrogExtension.class)
@Testcontainers
class AUCoreIT {
@Container
static GenericContainer<?> fhirServer = new GenericContainer<>("hapiproject/hapi:latest")
.withExposedPorts(8080);
@DynamicFhirServerUrl
static String getFhirServerUrl() {
return "http://localhost:" + fhirServer.getMappedPort(8080) + "/fhir";
}
@TestScript("classpath:fhir/patient-crud.json")
void testPatient() {}
}
Configuration¶
Server URL¶
Multiple ways to specify:
// 1. Annotation
@FhirServerUrl("http://localhost:8080/fhir")
// 2. Dynamic method
@DynamicFhirServerUrl
static String getUrl() {
return System.getenv("FHIR_SERVER_URL");
}
// 3. System property
-Dfhir.server.url=http://localhost:8080/fhir
TestScript Location¶
// Classpath
@TestScript("classpath:fhir/test.json")
// File system
@TestScript("file:///path/to/test.json")
// URL
@TestScript("http://example.org/TestScript/test")
Next Steps¶
- Maven Plugin - Build integration
- CLI - Standalone execution
- Best Practices - Testing patterns