2v0-7222 Exam QuestionsBrowse all questions from this exam

2v0-7222 Exam - Question 4


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

Show Answer
Correct Answer: A

Mocking a Spring Bean in a Spring Boot web slice test requires annotating it with @MockBean annotation. The @MockBean annotation is used to add mock beans to the Spring application context, overriding any existing bean definitions. This is useful for unit testing when you need to isolate your test from dependencies or test specific components in isolation.

Discussion

2 comments
Sign in to comment
james2033Option: A
Feb 16, 2024

The question may be incorrect. https://spring.io/blog/2016/08/30/custom-test-slice-with-spring-boot-1-4

PRASAD180Option: C
Apr 20, 2024

C is crt