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.
Loading...
Related Quiz
- The _____ is a specialized form of the @Component annotation intended to represent the application logic in Spring Boot.
- In Spring Boot, to capture and handle the MethodArgumentNotValidException, the _____ method in a controller advice can be used.
- Which of the following annotations is used to map a web request to a specific handler method?
- Which annotation in Spring is used to automate the wiring of bean dependencies?
- How would you design a Spring Cloud application to handle failovers and service unavailability, ensuring minimal impact on the user experience?