Bird
0
0

In Spring Boot testing, which annotation is used to indicate a test method?

easy📝 Syntax Q3 of 15
Spring Boot - Testing Spring Boot Applications
In Spring Boot testing, which annotation is used to indicate a test method?
A@Autowired
B@SpringBootTest
C@Test
D@Component
Step-by-Step Solution
Solution:
  1. Step 1: Identify the purpose of each annotation

    @Test marks a method as a test method to be run by the testing framework.
  2. Step 2: Understand other annotations

    @SpringBootTest is for integration testing, @Autowired injects dependencies, and @Component marks a bean.
  3. Final Answer:

    @Test -> Option C
  4. Quick Check:

    Test methods require @Test annotation [OK]
Quick Trick: Use @Test to mark test methods in Spring Boot [OK]
Common Mistakes:
  • Confusing @SpringBootTest with @Test
  • Using @Component instead of @Test
  • Forgetting to annotate test methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes