O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Custom names

The last feature related with parameterized tests in JUnit 5 has to do with the display name of each execution of tests. As we learned, a parameterized test is usually executed as several single tests. Therefore, for the shake of traceability, it is good practice to link each test execution with the argument source.

To that aim, the annotation @ParameterizedTest accepts an element called name in which we can specify a custom name (String) for the test execution. Moreover, in this String, we can use several built-in placeholders, as described in the following table:

Placeholder

Description

{index}

Current invocation index (first one is 1, second is 2, …)

{arguments}

Comma-separated arguments complete list

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required