I have a gradle project with 3 modules which use spring-boot. These 3 spring-boot applications are running in parallel and interact with each other.
For example, MODULE1 saves data in MODULE2 and MODULE3 retrieves data from MODULE2 via Rest APIs.
I would like to implement integration tests regarding the interactions between these 3 spring boot applications (ie. have each of them run separately on a different port). Is it possible? how?
I know we can do it for a single spring boot application. (as explained here)
The Spring Framework provides first-class support for integration testing in the spring-test module. The name of the actual JAR file might include the release version and might also be in the long org. springframework.
Have you ever considered using Docker? Like you I've had problem trying to do this and my current solution is to use docker-compose to stand up a container per application. I run each spring boot app in a simple container (example):
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD target/module1.jar app.jar
ENV JAVA_OPTS=""
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar
Then I use docker-compose to put it all together:
version: '3'
services:
module1:
build: ./path/to/module1/Dockerfile
ports:
- "8080:8080"
links:
- module2
module2:
build: ./path/to/module2/Dockerfile
ports:
- "8081:8081"
Please note that I haven't tested any of this config as I'm not on a dev machine just now and I've simplified the config to what I think is the bare minimum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With