Bird
0
0

What is the effect of annotating a test class with @SpringBootTest in a Spring Boot application?

easy📝 Conceptual Q1 of 15
Spring Boot - Testing Spring Boot Applications
What is the effect of annotating a test class with @SpringBootTest in a Spring Boot application?
AIt only loads the web layer beans for testing controllers.
BIt loads the complete application context for integration testing.
CIt mocks all service beans automatically.
DIt disables the Spring context loading to speed up tests.
Step-by-Step Solution
Solution:
  1. Step 1: Understand @SpringBootTest

    This annotation triggers loading of the full Spring Boot application context.
  2. Step 2: Differentiate from slice tests

    Unlike @WebMvcTest or @DataJpaTest, it does not limit context to specific layers.
  3. Final Answer:

    It loads the complete application context for integration testing. -> Option B
  4. Quick Check:

    Full context loading means integration testing [OK]
Quick Trick: Loads full Spring Boot context for integration tests [OK]
Common Mistakes:
  • Confusing @SpringBootTest with slice test annotations
  • Assuming it mocks beans automatically
  • Thinking it disables context loading

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes