nerdexam
Broadcom-VMware

2V0-72.22PSE · Question #24

Which two statements are true regarding Spring Boot Testing? (Choose two.)

The correct answer is C. @SpringBootTest is typically used for integration testing. D. Test methods annotated with @SpringBootTest will recreate the ApplicationContext. C is correct because @SpringBootTest loads the full Spring ApplicationContext, wiring together all layers (controllers, services, repositories), which is exactly what integration testing requires - verifying components work together end-to-end rather than in isolation. D is…

Testing

Question

Which two statements are true regarding Spring Boot Testing? (Choose two.)

Options

  • A@TestApplicationContext is used to define additional beans or customizations for a test.
  • BTest methods in a @SpringBootTest class are transactional by default.
  • C@SpringBootTest is typically used for integration testing.
  • DTest methods annotated with @SpringBootTest will recreate the ApplicationContext.
  • E@SpringBootTest without any configuration classes expects there is only one class annotated

How the community answered

(44 responses)
  • A
    5% (2)
  • B
    2% (1)
  • C
    91% (40)
  • E
    2% (1)

Explanation

C is correct because @SpringBootTest loads the full Spring ApplicationContext, wiring together all layers (controllers, services, repositories), which is exactly what integration testing requires - verifying components work together end-to-end rather than in isolation.

D is correct because @SpringBootTest triggers the creation of a real ApplicationContext for the test class. While Spring caches contexts between compatible test classes for performance, each distinct test configuration causes the context to be (re)created fresh.

Why the distractors are wrong:

  • A is wrong - the correct annotation is @TestConfiguration, not @TestApplicationContext (which doesn't exist in Spring).
  • B is wrong - @SpringBootTest tests are not transactional by default; you must explicitly annotate with @Transactional if you want rollback behavior.
  • E is wrong (though cut off) - @SpringBootTest without explicit configuration searches up the package hierarchy for a @SpringBootApplication-annotated class; it does not require exactly one such class.

Memory tip: Think of @SpringBootTest as "boots up the whole app for testing" - it's heavy (full context = integration test) and it builds the context fresh when the configuration changes. When you see @Test + full context = @SpringBootTest; when you see lightweight/isolated = unit test with mocks.

Topics

#Spring Boot Testing#@SpringBootTest annotation#Integration Testing#ApplicationContext

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice