Interface DisplayNameGenerator

    • Field Detail

      • DEFAULT_GENERATOR_PROPERTY_NAME

        @API(status=STABLE,
             since="5.9")
        static final java.lang.String DEFAULT_GENERATOR_PROPERTY_NAME
        Property name used to set the default display name generator class name: "junit.jupiter.displayname.generator.default"

        Supported Values

        Supported values include fully qualified class names for types that implement DisplayNameGenerator.

        If not specified, the default is DisplayNameGenerator.Standard.

        Since:
        5.5
        See Also:
        Constant Field Values
    • Method Detail

      • generateDisplayNameForClass

        java.lang.String generateDisplayNameForClass​(java.lang.Class<?> testClass)
        Generate a display name for the given top-level or static nested test class.

        If it returns null, the default display name generator will be used instead.

        Parameters:
        testClass - the class to generate a name for; never null
        Returns:
        the display name for the class; never blank
      • generateDisplayNameForNestedClass

        java.lang.String generateDisplayNameForNestedClass​(java.lang.Class<?> nestedClass)
        Generate a display name for the given @Nested inner test class.

        If it returns null, the default display name generator will be used instead.

        Parameters:
        nestedClass - the class to generate a name for; never null
        Returns:
        the display name for the nested class; never blank
      • generateDisplayNameForMethod

        java.lang.String generateDisplayNameForMethod​(java.lang.Class<?> testClass,
                                                      java.lang.reflect.Method testMethod)
        Generate a display name for the given method.

        If it returns null, the default display name generator will be used instead.

        Parameters:
        testClass - the class the test method is invoked on; never null
        testMethod - method to generate a display name for; never null
        Returns:
        the display name for the test; never blank
      • parameterTypesAsString

        static java.lang.String parameterTypesAsString​(java.lang.reflect.Method method)
        Generate a string representation of the formal parameters of the supplied method, consisting of the simple names of the parameter types, separated by commas, and enclosed in parentheses.
        Parameters:
        method - the method from to extract the parameter types from; never null
        Returns:
        a string representation of all parameter types of the supplied method or "()" if the method declares no parameters
      • getDisplayNameGenerator

        static DisplayNameGenerator getDisplayNameGenerator​(java.lang.Class<?> generatorClass)
        Return the DisplayNameGenerator instance corresponding to the given Class.
        Parameters:
        generatorClass - the generator's Class; never null, has to be a DisplayNameGenerator implementation
        Returns:
        a DisplayNameGenerator implementation instance