Im developing a solutions based on multiple spring boot microservices.
I wan to test end to end flows involving services calling each other,
What i planing to do is:
Create a new project, importing the projects (microservices)
create a Test and for each microservices create a mockservletcontext, something like:
@SpringBootMultiTest(clasess=[
Comment From: wilkinsona
Even if it were possible for MockMvc to call controllers in multiple different application contexts, I don't think the approach would work as the services would still not be able to call each other. For this to work the RestTemplate instances (or whatever you are using for inter-service communication) would also have to be modified.
Supporting something like this is out of the scope of Spring Boot. If you don't want to use mocks, you can either start all of the services and perform end-to-end testing or you could look at using Spring Cloud Contract.
Comment From: hugoviktor
Even if it were possible for
MockMvcto call controllers in multiple different application contexts, I don't think the approach would work as the services would still not be able to call each other. For this to work theRestTemplateinstances (or whatever you are using for inter-service communication) would also have to be modified.Supporting something like this is out of the scope of Spring Boot. If you don't want to use mocks, you can either start all of the services and perform end-to-end testing or you could look at using Spring Cloud Contract.
you dont need to modify the RestTemplate at all, you can use a MockMvcClientHttpRequestFactory, and have a mockMvc for each context. Ok, i going to try it follow the source code.