nerdexam
Broadcom-VMware

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) +…

Testing

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)
  • A
    4% (2)
  • B
    94% (47)
  • E
    2% (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 (from spring-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 - @Mock comes from the Mockito library, and @MockBean comes from spring-boot-test, not spring-test. The spring-test module provides things like @ContextConfiguration and @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

#Spring Boot Testing#Mocking with Mockito#@SpringBootTest annotation#Testing frameworks

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice