MikeJ
MikeJ

Reputation: 2437

Integration Testing against a service in docker

I have a microservice which I am testing (Java maven project with JUnit). This has a dependency on another microservice. I am writing an e-2-e system test and want to spin up the external service from a Docker image for a full automated test.

My question is what is the best way to have a maven project spin up a docker image instance which can then be used in an automated test suite?

At the moment I a using maven-exec plugin to call a shell script during the integration-phase which starts the docker container. It may not be the most elegant solution, and I also have no way of knowing when the container is ready.

Any thoughts or help would be appreciated.

Please note: This is for full system testing against real services so I don't want to mock or stub the external service.

Upvotes: 3

Views: 667

Answers (1)

thomas77
thomas77

Reputation: 1150

Take a look at Spotify maven plugin for docker or Fabric8 maven pluign

Fabric8 has goals as build, run and stop. This may not help you knowing if a container is ready for testing. (Could you have a sort of ping service in your test code that suspended tests until you got a OK 200?)

Upvotes: 2

Related Questions