All quizzes
Free quiz · 40 questions in the bank

JUnit quiz

Test your JUnit knowledge with a free interactive quiz — 40 questions with answers and explanations. No signup needed to play.

Question 1/12Score 0

What is the purpose of the @Before annotation?

In this round
  1. What is the purpose of the @Before annotation?
  2. Which static class provides JUnit 4's core assertion methods like assertEquals and assertTrue?
  3. What happens if an @Test method throws an unexpected (unhandled) exception during execution?
  4. What is a JUnit 4 test suite (@RunWith(Suite.class) with @Suite.SuiteClasses)?
  5. Which annotation marks a method as a test case in classic JUnit?
  6. How many instances of a test class does JUnit typically create when running a class with 3 @Test methods?
  7. What does @Test(expected = IllegalArgumentException.class) do?
  8. In Mockito, what does @Mock do when applied to a field in a test class run with MockitoJUnitRunner?
  9. What does when(paymentGateway.charge(anyString(), any(BigDecimal.class))).thenReturn(true) do?
  10. What does assertEquals(expected, actual) check?
  11. What is JUnit?
  12. What is the purpose of the @After annotation?
Gaps to close?
Read the curated JUnit notes — core concepts, patterns, interview prep.
JUnit notes

More quizzes

.NETAccessibilityAgile MethodologyAlertmanagerAlgorithmsAndroid