Package org.junit.jupiter.api
Interface DisplayNameGenerator
-
- All Known Implementing Classes:
DisplayNameGenerator.ReplaceUnderscores,DisplayNameGenerator.Standard
@API(status=EXPERIMENTAL, since="5.4") public interface DisplayNameGeneratorDisplayNameGeneratordefines 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.
- Since:
- 5.4
- See Also:
@DisplayName,@DisplayNameGeneration
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classDisplayNameGenerator.ReplaceUnderscoresDisplayNameGeneratorthat replaces underscores with spaces.static classDisplayNameGenerator.StandardStandardDisplayNameGenerator.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgenerateDisplayNameForClass(java.lang.Class<?> testClass)Generate a display name for the given top-level orstaticnested test class.java.lang.StringgenerateDisplayNameForMethod(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)Generate a display name for the given method.java.lang.StringgenerateDisplayNameForNestedClass(java.lang.Class<?> nestedClass)Generate a display name for the given@Nestedinner test class.static java.lang.StringparameterTypesAsString(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.
-
-
-
Method Detail
-
generateDisplayNameForClass
java.lang.String generateDisplayNameForClass(java.lang.Class<?> testClass)
Generate a display name for the given top-level orstaticnested test class.- Parameters:
testClass- the class to generate a name for; nevernull- Returns:
- the display name for the class; never
nullor blank
-
generateDisplayNameForNestedClass
java.lang.String generateDisplayNameForNestedClass(java.lang.Class<?> nestedClass)
Generate a display name for the given@Nestedinner test class.- Parameters:
nestedClass- the class to generate a name for; nevernull- Returns:
- the display name for the nested class; never
nullor blank
-
generateDisplayNameForMethod
java.lang.String generateDisplayNameForMethod(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)Generate a display name for the given method.- Parameters:
testClass- the class the test method is invoked on; nevernulltestMethod- method to generate a display name for; nevernull- Returns:
- the display name for the test; never
nullor blank - Implementation Note:
- The class instance supplied as
testClassmay differ from the class returned bytestMethod.getDeclaringClass()— for example, when a test method is inherited from a superclass.
-
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; nevernull- Returns:
- a string representation of all parameter types of the supplied
method or
"()"if the method declares no parameters
-
-