Using maven-failsafe with fabric8-maven to run integration tests that hit a containerised DB Using maven-failsafe with fabric8-maven to run integration tests that hit a containerised DB docker docker

Using maven-failsafe with fabric8-maven to run integration tests that hit a containerised DB


There are serveral examples for the docker-maven-plugin which show how the bindings work:

  • https://github.com/fabric8io/docker-maven-plugin/blob/master/samples/data-jolokia-demo/ contains various configurations variants for running integrations tests where in the pre-test phase a tomcat is fired up, the application deployed, the tests run, and then the tomcat teared down.

  • https://github.com/rhuss/docker-maven-sample is probably more interesting for you as it covers your use case with starting a Postgres db before the integration test (inclusive waiting until the DB is completely started). The binding is shown here :

    <executions>  <execution>    <id>start</id>    <phase>pre-integration-test</phase>    <goals>      <goal>build</goal>      <goal>start</goal>    </goals>  </execution>  <execution>    <id>stop</id>    <phase>post-integration-test</phase>    <goals>      <goal>stop</goal>    </goals>  </execution></executions>

But I recommend to examine the pom.xml there in more details, since it has even more info e.g. for how to setup the wait section. Feel free to open issues in this project if something is still unclear.


The way we recommend integration and system testing in maven with docker is via the fabric8 arquillian plugin. That takes care of creating a new namespace for the test and provisioning all the kubernetes resources then running your JUnit test case to run the assertions etc.

You'll need a docker image for the database and to wrap that up in a kubernetes yaml/json file so that it can be run up front as your app is deployed by fabric8-arquillian