VMware vRealize Automation 8.x (2022) — Question 51

Which option is true about use of mocks in a Spring Boot web slice test? (Choose the best answer.)

Answer options

Correct answer: A

Explanation

The correct answer is A because the @MockBean annotation is specifically designed for replacing beans in the Spring context with mock instances during testing. Option B is incorrect as existing beans can be mocked with the right annotations. Options C and D are also wrong; mocks can be used in tests, but @Mock alone does not integrate with the Spring context like @MockBean does.