2V0-72.22PSE · Question #65
Which two statements are true regarding Spring and Spring Boot Testing? (Choose two.)
The correct answer is B. @SpringBootTest or @SpringJUnitConfig can be used for creating an ApplicationContext. C. Mockito spy is not supported in Spring Boot testing by default. Note: The provided answer key (B, C) appears to contain an error. The actual correct answers are most likely B and E. B is correct because both @SpringBootTest (Spring Boot) and @SpringJUnitConfig (spring-test, combining @ExtendWith(SpringExtension.class) +…
Question
Which two statements are true regarding Spring and Spring Boot Testing? (Choose two.)
Options
- AEasyMock is supported out of the box.
- B@SpringBootTest or @SpringJUnitConfig can be used for creating an ApplicationContext.
- CMockito spy is not supported in Spring Boot testing by default.
- DThe spring-test dependency provides annotations such as @Mock and @MockBean.
- EIntegration and slice testing are both supported.
How the community answered
(50 responses)- A4% (2)
- B94% (47)
- E2% (1)
Explanation
Note: The provided answer key (B, C) appears to contain an error. The actual correct answers are most likely B and E.
B is correct because both @SpringBootTest (Spring Boot) and @SpringJUnitConfig (spring-test, combining @ExtendWith(SpringExtension.class) + @ContextConfiguration) are valid ways to bootstrap an ApplicationContext for testing.
E is correct because Spring Boot natively supports both full integration testing via @SpringBootTest (loads the entire context) and slice testing via annotations like @WebMvcTest, @DataJpaTest, and @JsonTest (loads only a relevant subset of the context).
Why the distractors are wrong:
- A - Spring Boot Test bundles Mockito out of the box, not EasyMock.
- C - This is false;
@SpyBean(fromspring-boot-test) wraps a real Spring bean as a Mockito spy, so spy support is included by default. This is likely why the answer key is wrong. - D -
@Mockcomes from the Mockito library, and@MockBeancomes fromspring-boot-test, notspring-test. Thespring-testmodule provides things like@ContextConfigurationand@Transactional.
Memory tip: Think "Boot = Full or Slice, both covered." @SpringBootTest = full app, @WebMvcTest/@DataJpaTest = slices. And remember that Mockito (not EasyMock) is Spring Boot's built-in mock framework, with both @MockBean and @SpyBean available.
Topics
Community Discussion
No community discussion yet for this question.