Can integration tests be run at the same time in many spring boot applications?

I have a gradle project with 3 modules that use spring-boot. These 3 spring-boot applications run in parallel and interact with each other.

For example, MODULE1 saves data in MODULE2, and MODULE3 retrieves data from MODULE2 through the Rest APIs.

I would like to implement integration tests regarding the interaction between these 3 spring boot applications (i.e. each of them runs separately on a different port). Is it possible? as?

I know that we can do this for a single spring boot application. ( as described here )

+6
source share
1 answer

Have you ever considered using Docker? Like you, I had a problem trying to do this, and my current solution is to use docker-compose to support the container for each application. I run each spring boot application 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 have not tested any of these configurations since I am not on a dev machine right now and I have simplified the configuration to what is, in my opinion, minimal.

+1
source

Source: https://habr.com/ru/post/988196/


All Articles