I'd like to write a end to end test for a pipeline, built with spring boot.
Consider two microservices A, B where B consumes output from A and produces a RESTful API. They are connected using rabbitmq and rely on an external database.
I would like to achieve something like:
Essentially replacing the white parts with mocks and testing the coloured parts.
Does this make sense? Test coverage of A and B is not complete and such a test would guarantee that the contract between A and B holds. Are there better ways?
I would recommend you to use Spring-cloud-contract . It helps you in maintaining contract between your microservices(Producer-Consumer Contracts). It's available for both HTTP based and event-based communication.
My first idea about this topic is that if it is an end-to-end test, then you should forget which framework do you use, because that relates to implementation in this context. So I would create a test project, which is essentially a docker-compose file, and defines 5 containers for
From this perspective you have 2 ways of handling env-specific configuration:
SPRING_PROFILES_ACTIVE
env var in the docker-compose file The test runner can be kept simple, I would write a JUnit-based test suite which uses RestAssured, or something similar.
I hope this gives a clue. Of course it is a broad topic so going into every detail doesn't fit into a SO answer.
If you have the time, I suggest you to read this : https://martinfowler.com/articles/microservice-testing/
The purpose of end-to-end testing is not to do 100% of line coverage.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.