FeatureSpring Boot TestWeb MVC Test
ScopeIntegration testingUnit testing
LoadsFull application contextSpecified controller and dependencies
Ideal forTesting the entire applicationTesting the controller in isolation
SpeedSlowerFaster
  • 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

  1. https://gustavopeiretti.com/spring-boot-unit-test-rest-controller/