Back to Tech Interviews

JUnit Java Testing Interview

Curated 20+ questions covering JUnit 5 Jupiter architecture, common annotations, assertions, nested suites, and parallel configurations.

Total: 20 QuestionsLearned: 0 / 20 (0%)
Difficulty Filters

Tools & Options
Showing 20 of 20 questions
Beginner
What is JUnit, and what are the main differences between JUnit 4 and JUnit 5?
Beginner
List common JUnit 5 annotations and their JUnit 4 equivalents.
Intermediate
How do you test that a method throws an exception in JUnit 5?
Intermediate
Explain Parameterized Tests in JUnit 5.
Beginner
What are assertions in JUnit? List some common ones.
Advanced
Explain the difference between `assertTimeout()` and `assertTimeoutPreemptively()`.
Intermediate
What are Assumptions in JUnit 5, and how do they differ from Assertions?
Beginner
What is `@DisplayName` annotation?
Advanced
What is the Extension Model in JUnit 5, and what annotation replaces `@RunWith`?
Intermediate
Explain Grouped Assertions (`assertAll()`).
Intermediate
What is the default lifecycle of a test class instance in JUnit?
Intermediate
Explain `@Nested` tests in JUnit 5.
Beginner
What is the purpose of `@Tag` in JUnit 5?
Intermediate
How do you run parameterized tests with CSV data files?
Advanced
What is `@TempDir` in JUnit 5, and why is it used?
Advanced
What is a dynamic test in JUnit 5?
Advanced
How do you configure parallel test execution in JUnit 5?
Beginner
What is `@RepeatedTest` in JUnit 5?
Scenario
Explain the use of the `@Mock` and `@InjectMocks` annotations in Mockito JUnit tests.
Intermediate
How can you order the execution of test methods in JUnit 5?