How does the @WebMvcTest annotation in Spring Boot testing differ from @SpringBootTest in terms of loaded context?

  • Only the data layer components are loaded.
  • Only the web layer components are loaded.
  • The database is loaded.
  • The entire Spring application context is loaded.
The @WebMvcTest annotation is used for testing the web layer of a Spring Boot application. It loads only the web-related components, such as controllers, and mocks other components. In contrast, @SpringBootTest loads the entire application context, including all components.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *