Recall & Review
beginner
What is the purpose of the JUnit Extension Model?
The JUnit Extension Model allows you to add custom behavior to tests, such as setup, teardown, or modifying test execution, without changing the test code itself.
Click to reveal answer
beginner
Name two common extension points in JUnit 5's Extension Model.
Two common extension points are BeforeEachCallback and AfterEachCallback, which run code before and after each test method respectively.
Click to reveal answer
beginner
How do you register an extension in JUnit 5?
You can register an extension by annotating the test class or method with <code>@ExtendWith(YourExtension.class)</code>.Click to reveal answer
intermediate
What is the difference between
BeforeAllCallback and BeforeEachCallback?BeforeAllCallback runs once before all tests in a class, while BeforeEachCallback runs before each individual test method.Click to reveal answer
intermediate
Why is the JUnit Extension Model useful for test code maintenance?
It helps keep test code clean by separating reusable setup or teardown logic into extensions, making tests easier to read and maintain.
Click to reveal answer
Which annotation is used to apply a JUnit 5 extension to a test class?
✗ Incorrect
The correct annotation to register an extension in JUnit 5 is
@ExtendWith.What does the
AfterEachCallback interface allow you to do?✗ Incorrect
AfterEachCallback runs code after each test method finishes.Which of these is NOT a valid JUnit 5 extension point?
✗ Incorrect
TestCaseListener is not a JUnit 5 extension point.How often does
BeforeAllCallback run in a test class?✗ Incorrect
BeforeAllCallback runs once before all tests in the class.What is a key benefit of using the JUnit Extension Model?
✗ Incorrect
Extensions let you add reusable setup or teardown logic cleanly.
Explain how the JUnit Extension Model helps improve test code organization.
Think about how extensions reduce repeated code in tests.
You got /4 concepts.
Describe the difference between BeforeEachCallback and BeforeAllCallback in JUnit extensions.
Consider how often each callback runs during testing.
You got /4 concepts.