I couldn't really understand what was the purpose of such a test, let me explain...
Usually MockMvc is used to test the web layer of the application.
This means that under the hood spring runs "something" that can mimic the requests sent to controllers so that you could check that the annotations are placed correctly, the conversion of objects is done in a proper way, etc. In other words its like testing the controller, but it has nothing to do with services, DAOs, etc. Usually the references to the services from controller can be annotated with @MockBean
so that spring will create a stub for services and you'll be able to describe the interactions. Other things like DAOs should never be referenced from controllers anyway (don't them ? ;) ) but in general the same pattern of mocking out these dependencies is applicable here.
Technically its done as follows:
The web mvc test (when annotated properly) doesn't load the whole application context but a "slice" of it - only beans relevant for the web layer.
Now @SpringBootTest
annotation does something different. Its designed especially for spring boot application and allows to mimic the whole spring application load. Out of my head (maybe other colleagues will enrich this list), it "adds up" to the regular application context starting:
- Properties configuration management
- Starters (auto-configuration modules)
- Package structure specific scanning for Beans and configurations
Bottom line, it allows starting Spring Boot Test out of some specific configuration or the whole application, it has nothing to do with a web layer only.
So, what I don't understand is what exactly is expected to be tested here.
If your goal is testing a web layer, then you don't have to use Spring Boot annotation (in addition to what I've already explained, spring boot test takes much more time to load)
If your goal is testing the microservice at a whole or sometimes a specific slice of it, then you can use @SpringBootTest` annotation.