JUnit 5 interview questions — Easy

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

This topic slice is available to practise but is not yet part of our indexed set.

What this covers

JUnit 5 appears throughout Automation Testing interviews. At easy level, interviewers are typically checking that you know the fundamentals and can describe them precisely — definitions, defaults, and the basic mechanics. Work through these, then explain your answer out loud; the second part is what interviews actually test.

20 example questions

  1. 1. In JUnit, what does @CsvSource do or refer to?

    • A. Groups assertions so all are evaluated and failures reported together.
    • B. Marks a Jupiter test method.
    • C. Registers extensions such as MockitoExtension.
    • D. Supplies inline CSV rows to a parameterized test.correct

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

  2. 2. In the context of JUnit, assertAll is best described as:

    • A. Registers extensions such as MockitoExtension.
    • B. Supplies inline CSV rows to a parameterized test.
    • C. Runs a test a fixed number of times.
    • D. Groups assertions so all are evaluated and failures reported together.correct

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

  3. 3. What is the purpose of @CsvSource in JUnit?

    • A. Groups assertions so all are evaluated and failures reported together.
    • B. Marks a Jupiter test method.
    • C. Supplies inline CSV rows to a parameterized test.correct
    • D. Skips a test or class with an optional reason.

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

  4. 4. Which of the following best describes @CsvSource in JUnit?

    • A. Fails a test exceeding a time limit.
    • B. Registers extensions such as MockitoExtension.
    • C. Groups assertions so all are evaluated and failures reported together.
    • D. Supplies inline CSV rows to a parameterized test.correct

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

  5. 5. Which of the following best describes assertAll in JUnit?

    • A. Supplies inline CSV rows to a parameterized test.
    • B. Fails a test exceeding a time limit.
    • C. Injected object describing the current test.
    • D. Groups assertions so all are evaluated and failures reported together.correct

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

  6. 6. In JUnit, what does assertAll do or refer to?

    • A. Injected object describing the current test.
    • B. Supplies inline CSV rows to a parameterized test.
    • C. Runs a test a fixed number of times.
    • D. Groups assertions so all are evaluated and failures reported together.correct

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

  7. 7. Which of the following best describes @RepeatedTest in JUnit?

    • A. Supplies inline CSV rows to a parameterized test.
    • B. Runs a test a fixed number of times.correct
    • C. Injected object describing the current test.
    • D. Fails a test exceeding a time limit.

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

  8. 8. In JUnit, what does TestInfo do or refer to?

    • A. Skips a test or class with an optional reason.
    • B. Runs a test a fixed number of times.
    • C. Groups assertions so all are evaluated and failures reported together.
    • D. Injected object describing the current test.correct

    Why: TestInfo: Injected object describing the current test.

  9. 9. Which of the following best describes @Test in JUnit?

    • A. Runs a test a fixed number of times.
    • B. Marks a Jupiter test method.correct
    • C. Fails a test exceeding a time limit.
    • D. Skips a test or class with an optional reason.

    Why: @Test: Marks a Jupiter test method.

  10. 10. Which of the following best describes @ExtendWith in JUnit?

    • A. Registers extensions such as MockitoExtension.correct
    • B. Supplies inline CSV rows to a parameterized test.
    • C. Runs a test a fixed number of times.
    • D. Fails a test exceeding a time limit.

    Why: @ExtendWith: Registers extensions such as MockitoExtension.

  11. 11. In JUnit, what does @RepeatedTest do or refer to?

    • A. Groups assertions so all are evaluated and failures reported together.
    • B. Runs a test a fixed number of times.correct
    • C. Registers extensions such as MockitoExtension.
    • D. Fails a test exceeding a time limit.

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

  12. 12. What is the purpose of @Timeout in JUnit?

    • A. Fails a test exceeding a time limit.correct
    • B. Marks a Jupiter test method.
    • C. Supplies inline CSV rows to a parameterized test.
    • D. Skips a test or class with an optional reason.

    Why: @Timeout: Fails a test exceeding a time limit.

  13. 13. What is the purpose of @ExtendWith in JUnit?

    • A. Skips a test or class with an optional reason.
    • B. Marks a Jupiter test method.
    • C. Registers extensions such as MockitoExtension.correct
    • D. Fails a test exceeding a time limit.

    Why: @ExtendWith: Registers extensions such as MockitoExtension.

  14. 14. Which of the following best describes @Disabled in JUnit?

    • A. Fails a test exceeding a time limit.
    • B. Registers extensions such as MockitoExtension.
    • C. Skips a test or class with an optional reason.correct
    • D. Runs a test a fixed number of times.

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

  15. 15. In JUnit, what does @ExtendWith do or refer to?

    • A. Registers extensions such as MockitoExtension.correct
    • B. Runs a test a fixed number of times.
    • C. Supplies inline CSV rows to a parameterized test.
    • D. Groups assertions so all are evaluated and failures reported together.

    Why: @ExtendWith: Registers extensions such as MockitoExtension.

  16. 16. In JUnit, what does @Test do or refer to?

    • A. Marks a Jupiter test method.correct
    • B. Injected object describing the current test.
    • C. Registers extensions such as MockitoExtension.
    • D. Skips a test or class with an optional reason.

    Why: @Test: Marks a Jupiter test method.

  17. 17. What is the purpose of TestInfo in JUnit?

    • A. Marks a Jupiter test method.
    • B. Injected object describing the current test.correct
    • C. Skips a test or class with an optional reason.
    • D. Registers extensions such as MockitoExtension.

    Why: TestInfo: Injected object describing the current test.

  18. 18. In JUnit, what does @Disabled do or refer to?

    • A. Injected object describing the current test.
    • B. Marks a Jupiter test method.
    • C. Skips a test or class with an optional reason.correct
    • D. Groups assertions so all are evaluated and failures reported together.

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

  19. 19. Which of the following best describes @Timeout in JUnit?

    • A. Groups assertions so all are evaluated and failures reported together.
    • B. Fails a test exceeding a time limit.correct
    • C. Marks a Jupiter test method.
    • D. Registers extensions such as MockitoExtension.

    Why: @Timeout: Fails a test exceeding a time limit.

  20. 20. What is the purpose of @RepeatedTest in JUnit?

    • A. Injected object describing the current test.
    • B. Skips a test or class with an optional reason.
    • C. Registers extensions such as MockitoExtension.
    • D. Runs a test a fixed number of times.correct

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

Related Automation Testing topics