Package org.junit.jupiter.api
Interface DisplayNameGenerator
-
- All Known Implementing Classes:
DisplayNameGenerator.ReplaceUnderscores
,DisplayNameGenerator.Standard
@API(status=EXPERIMENTAL, since="5.4") public interface DisplayNameGenerator
DisplayNameGenerator
defines the SPI for generating display names programmatically.An implementation must provide an accessible no-arg constructor.
- Since:
- 5.4
- See Also:
DisplayName
,DisplayNameGeneration
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DisplayNameGenerator.ReplaceUnderscores
Replace all underscore characters with spaces.static class
DisplayNameGenerator.Standard
Standard display name generator.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
generateDisplayNameForClass(java.lang.Class<?> testClass)
Generate a display name for the given top-level orstatic
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)
Compile a string representation from all simple parameter type names.
-
-
-
Method Detail
-
generateDisplayNameForClass
java.lang.String generateDisplayNameForClass(java.lang.Class<?> testClass)
Generate a display name for the given top-level orstatic
nested test class.- Parameters:
testClass
- the class generate a name for; nevernull
- Returns:
- the display name of the container; never
null
or blank
-
generateDisplayNameForNestedClass
java.lang.String generateDisplayNameForNestedClass(java.lang.Class<?> nestedClass)
Generate a display name for the given@Nested
inner test class.- Parameters:
nestedClass
- the class generate a name for; nevernull
- Returns:
- the display name of the container; never
null
or 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; nevernull
testMethod
- method to generate a display name for; nevernull
- Returns:
- the display name of the test; never
null
or blank - Implementation Note:
- The class instance passed as
testClass
may differ from the returned class bytestMethod.getDeclaringClass()
: e.g., when a test method is inherited from a super class.
-
parameterTypesAsString
static java.lang.String parameterTypesAsString(java.lang.reflect.Method method)
Compile a string representation from all simple parameter type names.- Parameters:
method
- the method providing parameter types for the result; nevernull
- Returns:
- a string representation of all parameter types of the
supplied method or
"()"
if the method has no parameters
-
-