QuizzesSpring Boot Testing with JUnit 5: Beginner's Guide
beginner
spring

Spring Boot Testing with JUnit 5: Beginner's Guide

An introductory quiz on testing Spring Boot applications using JUnit 5.

15 minutes 15 questions Pass at 70%
Time Limit
15 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

15 questions on Spring Boot Testing with JUnit 5: Beginner's Guide. Work through them here, then start the quiz to answer them and see your score.

  1. 1.What annotation is used to indicate a test method in JUnit 5?

    • A@RunWith
    • B@Test
    • C@BeforeEach
    • D@SpringBootTest
  2. 2.Which annotation is used to load the Spring ApplicationContext for testing?

    • A@EnableAutoConfiguration
    • B@ContextConfiguration
    • C@TestConfiguration
    • D@SpringBootTest
  3. 3.What is the purpose of the @BeforeEach annotation in JUnit 5?

    • ATo run code after each test method
    • BTo run code before each test method
    • CTo run code after all test methods
    • DTo run code before all test methods
  4. 4.Which of the following is NOT a valid JUnit 5 assertion?

    • AassertEquals
    • BassertTrue
    • CassertArrayEquals
    • DassertSame
  5. 5.How do you disable a test in JUnit 5?

    • A@Exclude
    • B@Disabled
    • C@Skip
    • D@Ignore
  6. 6.What is the purpose of the @ExtendWith annotation in JUnit 5?

    • ATo provide test data
    • BTo extend test classes with additional functionality
    • CTo run tests in parallel
    • DTo ignore certain tests
  7. 7.Which annotation is used to specify that a method should be run after each test method?

    • A@BeforeEach
    • B@AfterAll
    • C@AfterEach
    • D@BeforeAll
  8. 8.What is the correct way to assert that two objects are equal in JUnit 5?

    • AassertSame(expected, actual)
    • BassertEquals(expected, actual)
    • CassertThat(expected).isEqualTo(actual)
    • DassertTrue(expected == actual)
  9. 9.How do you specify a timeout for a test in JUnit 5?

    • A@Test(timeLimit = 1000)
    • B@Timeout
    • C@Test(duration = 1000)
    • D@Test(timeout = 1000)
  10. 10.Which annotation is used to run a block of code once before all tests in a class?

    • A@AfterEach
    • B@BeforeEach
    • C@AfterAll
    • D@BeforeAll
  11. 11.What is the purpose of the @Nested annotation in JUnit 5?

    • ATo disable a group of tests
    • BTo group related test classes
    • CTo create nested test classes
    • DTo run tests in a specific order
  12. 12.How can you run a test with different sets of data in JUnit 5?

    • A@TestFactory
    • B@ParameterizedTest
    • C@RepeatedTest
    • D@DataProvider
  13. 13.Which annotation is used to repeat a test a specified number of times in JUnit 5?

    • A@RepeatedTest
    • B@CycleTest
    • C@LoopTest
    • D@TimesTest
  14. 14.What is the purpose of the @TestInstance annotation in JUnit 5?

    • ATo create test instances
    • BTo destroy test instances
    • CTo configure test instances
    • DTo specify the lifecycle of test instances
  15. 15.Which annotation is used to indicate that a method is a factory for dynamic tests in JUnit 5?

    • A@TestSource
    • B@TestProvider
    • C@DynamicTest
    • D@TestFactory