Feature | Spring Boot Test | Web MVC Test |
---|
Scope | Integration testing | Unit testing |
Loads | Full application context | Specified controller and dependencies |
Ideal for | Testing the entire application | Testing the controller in isolation |
Speed | Slower | Faster |
- The main difference between Spring Boot Test and Web MVC Test is the scope of the test
- Spring Boot Test starts the full application context, including all of the beans that are defined in the application. This makes it ideal for testing the entire application, including the interactions between different components.
- Web MVC Test, on the other hand, only loads the specified controller and its dependencies. This makes it ideal for testing the controller in isolation, without having to worry about the rest of the application.
Refs §
- https://gustavopeiretti.com/spring-boot-unit-test-rest-controller/