Recall & Review
beginner
What is the purpose of custom display names for parameters in JUnit tests?
Custom display names make test output easier to read by showing meaningful names for parameters instead of default values or indexes.
Click to reveal answer
beginner
How do you specify a custom display name for a parameter in a JUnit 5 parameterized test?
Use the @ParameterizedTest annotation with the name attribute, for example: @ParameterizedTest(name = "Test with input={0} and expected={1}").
Click to reveal answer
intermediate
What placeholders can you use in the name attribute for custom display names in JUnit 5 parameterized tests?
You can use placeholders like {index} for the invocation index, {0}, {1}, etc. for parameter values by position.
Click to reveal answer
beginner
Why is using custom display names for parameters helpful when running tests in an IDE or CI environment?
It helps quickly identify which input caused a test failure without digging into the code or logs, improving debugging speed.
Click to reveal answer
beginner
Show a simple example of a JUnit 5 parameterized test method with a custom display name for parameters.
@ParameterizedTest(name = "Run {index}: input={0}, expected={1}")
@CsvSource({"apple, 5", "banana, 6"})
void testLength(String input, int expected) {
assertEquals(expected, input.length());
}
Click to reveal answer
What annotation attribute in JUnit 5 allows you to set custom display names for parameterized test runs?
✗ Incorrect
The 'name' attribute in @ParameterizedTest sets the custom display name format.
Which placeholder represents the current test invocation index in a JUnit 5 parameterized test name?
✗ Incorrect
The placeholder '{index}' shows the current invocation number starting at 1.
In the name attribute, how do you refer to the first parameter's value?
✗ Incorrect
Parameters are zero-indexed, so '{0}' refers to the first parameter.
Why should you use custom display names for parameters in tests?
✗ Incorrect
Custom display names improve readability of test results, especially on failures.
Which JUnit 5 annotation is used to run a test multiple times with different parameters?
✗ Incorrect
@ParameterizedTest runs the same test method with different parameters.
Explain how to create custom display names for parameters in a JUnit 5 parameterized test and why it is useful.
Think about how test output looks and how placeholders work.
You got /4 concepts.
Describe the placeholders available for custom display names in JUnit 5 parameterized tests and give an example of their usage.
Focus on how to refer to parameters and the test run number.
You got /3 concepts.