Skip to content

Maven Plugin

Execute FHIR tests during Maven build lifecycle.

Perfect for HAPI FHIR and SMILE CDR

Maven plugin integration is ideal for HAPI FHIR and SMILE CDR projects. Integrate FHIR conformance testing directly into your Maven build and test suites.

Setup

<plugin>
    <groupId>org.fhirfrog</groupId>
    <artifactId>fhir-frog-maven-plugin</artifactId>
    <version>${fhir-frog.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>test</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Configuration

Single TestScript

<configuration>
    <testScript>src/test/resources/fhir/patient-crud.json</testScript>
    <serverUrl>http://localhost:8080/fhir</serverUrl>
</configuration>

Multiple TestScripts

<configuration>
    <testScripts>
        <testScript>src/test/resources/fhir/patient-crud.json</testScript>
        <testScript>src/test/resources/fhir/practitioner-crud.json</testScript>
    </testScripts>
    <serverUrl>http://localhost:8080/fhir</serverUrl>
</configuration>

TestPlan

<configuration>
    <testPlan>TestPlan/au-core-suite</testPlan>
    <serverUrl>http://localhost:8080/fhir</serverUrl>
</configuration>

Report Generation

<configuration>
    <serverUrl>http://localhost:8080/fhir</serverUrl>
    <testScript>src/test/resources/fhir/test.json</testScript>
    <reportDir>target/fhir-reports</reportDir>
    <reportFormat>json</reportFormat>
</configuration>

Formats: json, xml, both

Lifecycle Binding

Integration Tests

<execution>
    <phase>integration-test</phase>
    <goals>
        <goal>test</goal>
    </goals>
</execution>

Verify Phase

<execution>
    <phase>verify</phase>
    <goals>
        <goal>test</goal>
    </goals>
</execution>

Server Management

With Testcontainers

<plugin>
    <groupId>io.fabric8</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>start-fhir-server</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
        <execution>
            <id>stop-fhir-server</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.fhirfrog</groupId>
    <artifactId>fhir-frog-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>integration-test</phase>
            <goals>
                <goal>test</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Skip Tests

mvn verify -Dfhir.skip=true

Configuration:

<configuration>
    <skip>${fhir.skip}</skip>
</configuration>

Complete Example

<build>
    <plugins>
        <plugin>
            <groupId>org.fhirfrog</groupId>
            <artifactId>fhir-frog-maven-plugin</artifactId>
            <version>${fhir-frog.version}</version>
            <executions>
                <execution>
                    <id>test-au-core</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <testPlan>TestPlan/au-core-complete</testPlan>
                        <serverUrl>${fhir.server.url}</serverUrl>
                        <reportDir>${project.build.directory}/fhir-reports</reportDir>
                        <reportFormat>both</reportFormat>
                        <failOnError>true</failOnError>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Next Steps

  • CLI - Standalone execution
  • Ant Task - Ant integration
  • JUnit - Direct JUnit usage