@API(status=EXPERIMENTAL,
since="5.4")
public interface DisplayNameGenerator
DisplayNameGenerator defines the SPI for generating display names
programmatically.
Display names are typically used for test reporting in IDEs and build tools and may contain spaces, special characters, and even emoji.
Concrete implementations must have a default constructor.
@DisplayName,
@DisplayNameGeneration| Modifier and Type | Interface and Description |
|---|---|
static class |
DisplayNameGenerator.ReplaceUnderscores
DisplayNameGenerator that replaces underscores with spaces. |
static class |
DisplayNameGenerator.Standard
Standard
DisplayNameGenerator. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
generateDisplayNameForClass(java.lang.Class<?> testClass)
Generate a display name for the given top-level or
static nested test class. |
java.lang.String |
generateDisplayNameForMethod(java.lang.Class<?> testClass,
java.lang.reflect.Method testMethod)
Generate a display name for the given method.
|
java.lang.String |
generateDisplayNameForNestedClass(java.lang.Class<?> nestedClass)
Generate a display name for the given
@Nested inner test class. |
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.
|
java.lang.String generateDisplayNameForClass(java.lang.Class<?> testClass)
static nested test class.testClass - the class to generate a name for; never nullnull or blankjava.lang.String generateDisplayNameForNestedClass(java.lang.Class<?> nestedClass)
@Nested inner test class.nestedClass - the class to generate a name for; never nullnull or blankjava.lang.String generateDisplayNameForMethod(java.lang.Class<?> testClass,
java.lang.reflect.Method testMethod)
testClass - the class the test method is invoked on; never nulltestMethod - method to generate a display name for; never nullnull or blankstatic java.lang.String parameterTypesAsString(java.lang.reflect.Method method)
method - the method from to extract the parameter types from; never
null"()" if the method declares no parameters