QuizzesMastering Spring Boot Integration Testing
advanced
spring

Mastering Spring Boot Integration Testing

An advanced quiz on integration testing techniques in Spring Boot applications.

20 minutes 10 questions Pass at 70%
Time Limit
20 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

10 questions on Mastering Spring Boot Integration Testing. Work through them here, then start the quiz to answer them and see your score.

  1. 1.In Spring Boot, which annotation is used to load the complete application context for integration tests?

    • A@DataJpaTest
    • B@SpringBootTest
    • C@MockBean
    • D@WebMvcTest
  2. 2.Which of the following is true about using @MockBean in Spring Boot integration tests?

    • AIt creates a new application context for each test.
    • BIt replaces a bean in the application context with a mock.
    • CIt is used to mock HTTP requests.
    • DIt is used to mock database transactions.
  3. 3.How can you ensure a specific profile is active during a Spring Boot integration test?

    • ASet the profile in application.properties
    • BUse @Profile annotation
    • CUse @ActiveProfiles annotation
    • DSet the profile in application.yml
  4. 4.What is the purpose of @TestPropertySource in Spring Boot tests?

    • ATo mock external services
    • BTo specify test execution order
    • CTo define custom properties for tests
    • DTo configure database connections
  5. 5.Which annotation would you use to test REST controllers in isolation in Spring Boot?

    • A@RestControllerTest
    • B@MockMvcTest
    • C@WebMvcTest
    • D@SpringBootTest
  6. 6.In Spring Boot, how can you test a component that interacts with a database without affecting the actual database?

    • AUse @MockBean
    • BUse @DataJpaTest
    • CUse @Transactional
    • DUse an embedded database
  7. 7.What is the role of @AutoConfigureMockMvc in Spring Boot tests?

    • ATo mock service layer beans
    • BTo configure MockMvc for testing controllers
    • CTo enable asynchronous testing
    • DTo configure database connections
  8. 8.Which annotation is used to test JPA repositories in Spring Boot?

    • A@RepositoryTest
    • B@DataJpaTest
    • C@JpaRepositoryTest
    • D@JpaTest
  9. 9.How can you verify that a Spring Boot application context loads successfully in a test?

    • AUse @ComponentScan
    • BUse @EnableAutoConfiguration
    • CUse @SpringBootTest without any additional configuration
    • DUse @ContextConfiguration
  10. 10.What is the advantage of using @DirtiesContext in Spring Boot tests?

    • AIt marks the context as dirty, forcing a reload for subsequent tests.
    • BIt cleans the database after each test.
    • CIt mocks all beans in the context.
    • DIt disables caching in tests.