I'm currently writing integration tests between 2 modules:
- Module A - contains a REST service which can be dockerized via maven plugin
- Module B - contains integration tests which depends on Module A docker to be up and running
So I used failsafe plugin which contains the pre-integration-tests phase and post-integration-tests.
In the pre-integration-tests I start the dockers and after all the integration tests of all the submodules have finished I want to kill those dockers.
In the docker plugin that I use (fabric8) there is also 2 phases which I use in the above phases which area docker:start and docker:stop
The problem appears when I run the entire project, the dockers are killed in Module A before Module B tests are running, so I thought that if I could tell the parent module which holds them something like :
- Start Module B docker:start plugin
- Run integration tests of all project
- Start Module B docker:stop plugin
It would really solve my problem, but is there a way to call phases of submodules from parent module or even revered, attach a submodule phase to the parent module phase from the submodule
As far as I understand your setup, building
Module A
has nothing to do with starting/stopping containers; thus,Module A
shouldn’t do it.Instead, the container should be started and stopped in
Module B
’spre-integration-test
andpost-integration-test
phases, respectively. After all,Module B
’sintegration-test
phase needs a running container, notModule A
.If you are not used to Maven’s (opinionated) way of doing things, this may seem unnecessarily restrictive, but Maven merely forces you to do the Right Thing. Think about it like this: If, in the future, another
Module C
also needs a running docker container, e.g., to run some other tests against, you wouldn’t want to recycle a single docker container (started byModule A
). As this risksModule B
andModule C
interacting in funny ways, each module should get its own docker container to work against.