Recall & Review
beginner
What is the purpose of the @DisplayName annotation in JUnit?
The @DisplayName annotation is used to give a test method or class a readable and descriptive name that appears in test reports and IDEs, making tests easier to understand.Click to reveal answer
beginner
How do you use @DisplayName in a JUnit test method?
You place @DisplayName("Your readable name") above the test method to set a custom name that will show in test results instead of the method name.
Click to reveal answer
intermediate
Can @DisplayName be used on test classes as well as test methods?
Yes, @DisplayName can be applied to both test classes and test methods to provide readable names at both levels.
Click to reveal answer
beginner
What happens if you do not use @DisplayName in your tests?
If @DisplayName is not used, the test runner shows the method or class names as they are written in code, which may be less readable or descriptive.Click to reveal answer
beginner
Give an example of a @DisplayName annotation for a test method.
Example: @DisplayName("Check if user login succeeds with valid credentials")
void testUserLogin() { ... }
Click to reveal answer
What does the @DisplayName annotation do in JUnit?
✗ Incorrect
The @DisplayName annotation sets a readable and descriptive name for test classes or methods.
Where can you apply the @DisplayName annotation?
✗ Incorrect
@DisplayName can be used on both test classes and test methods to improve readability.
If you omit @DisplayName, what name appears in test reports?
✗ Incorrect
Without @DisplayName, the test runner shows the method or class names exactly as they appear in the code.
Which of these is a valid use of @DisplayName?
✗ Incorrect
@DisplayName requires a string value describing the test; other types are invalid.
Why is using @DisplayName helpful?
✗ Incorrect
@DisplayName improves test report readability by showing descriptive names.
Explain how @DisplayName improves test readability and where you can apply it.
Think about how test names appear when running tests.
You got /3 concepts.
Describe what happens if you do not use @DisplayName in your JUnit tests.
Consider default naming behavior in test reports.
You got /3 concepts.