2.3.1. Display Name Generators

    JUnit Jupiter supports custom display name generators that can be configured via the @DisplayNameGeneration annotation. Values provided via @DisplayName annotations always take precedence over display names generated by a DisplayNameGenerator.

    Generators can be created by implementing DisplayNameGenerator. Here are some default ones available in Jupiter:

    Note that for IndicativeSentences, you can customize the separator and the underlying generator by using @IndicativeSentencesGeneration as shown in the following example.

    2.3.2. Setting the Default Display Name Generator

    For example, to use the ReplaceUnderscores display name generator by default, you should set the configuration parameter to the corresponding fully qualified class name (e.g., in src/test/resources/junit-platform.properties):

    Similarly, you can specify the fully qualified name of any custom class that implements DisplayNameGenerator.

    In summary, the display name for a test class or method is determined according to the following precedence rules:

    1. value of the @DisplayName annotation, if present