VMware vRealize Automation 8.x (2022) — Question 72
Which two statements are true regarding @WebMvcTest? (Choose two.)
Answer options
- A. It auto-configures a MockMvc.
- B. It will only scan for @Controller beans in the source code.
- C. It is used for testing Spring MVC components such as @Controller with a running server.
- D. Typically it is used in combination with @MockBean when there is a dependency bean to be mocked.
- E. It is typically used with @ExtendWith(MockitoExtension.class) in JUnit 5.
Correct answer: A, D
Explanation
@WebMvcTest is designed to auto-configure a MockMvc, making option A correct. Option D is also right as @WebMvcTest often works with @MockBean to mock dependencies. Options B and C are incorrect because @WebMvcTest can scan for more than just @Controller beans and does not require a running server for testing. Option E is not a typical requirement for using @WebMvcTest.