Bird
0
0

Which annotation is commonly used to enable Testcontainers support in a Spring Boot test class?

easy📝 Conceptual Q2 of 15
Spring Boot - Testing Spring Boot Applications
Which annotation is commonly used to enable Testcontainers support in a Spring Boot test class?
A@Testcontainers
B@DataJpaTest
C@Container
D@SpringBootTest
Step-by-Step Solution
Solution:
  1. Step 1: Identify Testcontainers enabling annotation

    The @Testcontainers annotation activates container lifecycle management in the test class.
  2. Step 2: Differentiate from other annotations

    @SpringBootTest and @DataJpaTest configure Spring context but do not manage containers; @Container marks container fields.
  3. Final Answer:

    @Testcontainers -> Option A
  4. Quick Check:

    Enable Testcontainers = @Testcontainers [OK]
Quick Trick: Use @Testcontainers to manage container lifecycle [OK]
Common Mistakes:
  • Using @Container alone without @Testcontainers
  • Confusing @SpringBootTest as container enabler
  • Mixing @DataJpaTest with container management

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes