Skip to content

JUnit 5 interview questions — Medium

201 medium-level JUnit 5 questions from our Automation Testing bank, each with the correct answer and an explanation of why it is correct.

What this covers

JUnit 5 appears throughout Automation Testing interviews. At medium level, interviewers are typically checking that you have used it in practice: what you configured, what broke, and how you knew it worked. Work through these, then explain your answer out loud; the second part is what interviews actually test.

Other levels:Hard (101)Easy (98)

20 example questions

  1. 1. "Supplies inline CSV rows to a parameterized test" — in JUnit, this describes which of the following?

    • A. @Disabled.
    • B. @RepeatedTest.
    • C. @CsvSource.correct
    • D. TestInfo.

    Why: @CsvSource: Supplies inline CSV rows to a parameterized test.

  2. 2. Which of the following statements about JUnit is TRUE?

    • A. JUnit 5 cannot run JUnit 4 tests under any circumstances.
    • B. JUnit 5 consists of the Platform, Jupiter, and Vintage modules.correct
    • C. Parameterized tests require the JUnit 4 @RunWith(Parameterized.class) runner in JUnit 5.
    • D. Assumptions that fail mark the test as failed in the report.

    Why: Jupiter is the new API; Vintage runs JUnit 4 tests on the platform.

  3. 3. Which JUnit 5 annotation runs a test with multiple argument sets?

    • A. @RepeatedTest.
    • B. @ParameterizedTest with a source.correct
    • C. @BeforeEach.
    • D. @Disabled.

    Why: @ParameterizedTest + a source runs once per argument set.

  4. 4. Identify the accurate statement about JUnit:

    • A. Parameterized tests require the JUnit 4 @RunWith(Parameterized.class) runner in JUnit 5.
    • B. JUnit 5 has no mechanism for tagging or filtering tests.
    • C. Assumptions that fail mark the test as failed in the report.
    • D. JUnit 5 consists of the Platform, Jupiter, and Vintage modules.correct

    Why: Jupiter is the new API; Vintage runs JUnit 4 tests on the platform.

  5. 5. "Runs a test a fixed number of times" — in JUnit, this describes which of the following?

    • A. @RepeatedTest.correct
    • B. AssertAll.
    • C. @Disabled.
    • D. @ExtendWith.

    Why: @RepeatedTest: Runs a test a fixed number of times.

  6. 6. "Registers extensions such as MockitoExtension" — in JUnit, this describes which of the following?

    • A. @Test.
    • B. TestInfo.
    • C. @ExtendWith.correct
    • D. @Timeout.

    Why: @ExtendWith: Registers extensions such as MockitoExtension.

  7. 7. "Marks a Jupiter test method" — in JUnit, this describes which of the following?

    • A. @CsvSource.
    • B. @Test.correct
    • C. @RepeatedTest.
    • D. TestInfo.

    Why: @Test: Marks a Jupiter test method.

  8. 8. "Injected object describing the current test" — in JUnit, this describes which of the following?

    • A. AssertAll.
    • B. TestInfo.correct
    • C. @RepeatedTest.
    • D. @CsvSource.

    Why: TestInfo: Injected object describing the current test.

  9. 9. Which statement correctly describes JUnit?

    • A. @BeforeAll runs before every single test method.
    • B. JUnit 5 consists of the Platform, Jupiter, and Vintage modules.correct
    • C. JUnit 5 tests must extend a base TestCase class.
    • D. Assumptions that fail mark the test as failed in the report.

    Why: Jupiter is the new API; Vintage runs JUnit 4 tests on the platform.

  10. 10. "Skips a test or class with an optional reason" — in JUnit, this describes which of the following?

    • A. @CsvSource.
    • B. TestInfo.
    • C. @Disabled.correct
    • D. @Test.

    Why: @Disabled: Skips a test or class with an optional reason.

  11. 11. In JUnit, which of the following is described as: "Supplies inline CSV rows to a parameterized test"?

    • A. @Disabled.
    • B. AssertAll.
    • C. @CsvSource.correct
    • D. @Timeout.

    Why: @CsvSource: Supplies inline CSV rows to a parameterized test.

  12. 12. In JUnit, which of the following is described as: "Groups assertions so all are evaluated and failures reported together"?

    • A. TestInfo.
    • B. AssertAll.correct
    • C. @CsvSource.
    • D. @Disabled.

    Why: assertAll: Groups assertions so all are evaluated and failures reported together.

  13. 13. Which JUnit concept matches this description: "Supplies inline CSV rows to a parameterized test"?

    • A. @CsvSource.correct
    • B. @RepeatedTest.
    • C. @Disabled.
    • D. TestInfo.

    Why: @CsvSource: Supplies inline CSV rows to a parameterized test.

  14. 14. In the context of JUnit, which of the following is a correct statement?

    • A. @ParameterizedTest with sources like @ValueSource or @CsvSource runs a test with multiple inputs.correct
    • B. JUnit 5 has no mechanism for tagging or filtering tests.
    • C. @BeforeAll runs before every single test method.
    • D. Assumptions that fail mark the test as failed in the report.

    Why: Parameterized tests replace repetitive copies of the same test.

  15. 15. In JUnit, which of the following is described as: "Runs a test a fixed number of times"?

    • A. @Timeout.
    • B. AssertAll.
    • C. @RepeatedTest.correct
    • D. @ExtendWith.

    Why: @RepeatedTest: Runs a test a fixed number of times.

  16. 16. Regarding JUnit, which statement is correct?

    • A. @ParameterizedTest with sources like @ValueSource or @CsvSource runs a test with multiple inputs.correct
    • B. JUnit 5 tests must extend a base TestCase class.
    • C. JUnit 5 cannot run JUnit 4 tests under any circumstances.
    • D. AssertThrows passes only if no exception is thrown.

    Why: Parameterized tests replace repetitive copies of the same test.

  17. 17. Which JUnit concept matches this description: "Registers extensions such as MockitoExtension"?

    • A. @ExtendWith.correct
    • B. @RepeatedTest.
    • C. @CsvSource.
    • D. TestInfo.

    Why: @ExtendWith: Registers extensions such as MockitoExtension.

  18. 18. Which JUnit concept matches this description: "Injected object describing the current test"?

    • A. @Disabled.
    • B. @ExtendWith.
    • C. TestInfo.correct
    • D. @CsvSource.

    Why: TestInfo: Injected object describing the current test.

  19. 19. In JUnit, which of the following is described as: "Marks a Jupiter test method"?

    • A. AssertAll.
    • B. @Test.correct
    • C. @Timeout.
    • D. TestInfo.

    Why: @Test: Marks a Jupiter test method.

  20. 20. In JUnit, which of the following is described as: "Registers extensions such as MockitoExtension"?

    • A. @ExtendWith.correct
    • B. TestInfo.
    • C. @CsvSource.
    • D. @Timeout.

    Why: @ExtendWith: Registers extensions such as MockitoExtension.

Related Automation Testing topics