Package org.junit.jupiter.api
Class DisplayNameGenerator.IndicativeSentences
java.lang.Object
org.junit.jupiter.api.DisplayNameGenerator.IndicativeSentences
- All Implemented Interfaces:
DisplayNameGenerator
- Enclosing interface:
DisplayNameGenerator
@API(status=EXPERIMENTAL,
since="5.7")
public static class DisplayNameGenerator.IndicativeSentences
extends Object
implements DisplayNameGenerator
DisplayNameGenerator
that generates complete sentences.
This implements the functionality of DisplayNameGenerator
by generating complete sentences display names, these
sentences are divided with a separator, and the generator and separator
can be customisable by using the IndicativeSentencesGeneration
interface as annotation.
- Since:
- 5.7
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.DisplayNameGenerator
DisplayNameGenerator.IndicativeSentences, DisplayNameGenerator.ReplaceUnderscores, DisplayNameGenerator.Simple, DisplayNameGenerator.Standard
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateDisplayNameForClass
(Class<?> testClass) Generate a display name for the given top-level orstatic
nested test class.generateDisplayNameForMethod
(Class<?> testClass, Method testMethod) Generate a display name for the given method.generateDisplayNameForNestedClass
(Class<?> nestedClass) Generate a display name for the given@Nested
inner test class.private DisplayNameGenerator
getGeneratorForIndicativeSentence
(Class<?> testClass) Gets the generator forIndicativeSentencesGeneration
when extracting the annotation fromIndicativeSentencesGeneration
, if it doesn't find it, then search for the parent classes, if no generator value is found useDisplayNameGenerator.Standard
by default.private Optional
<IndicativeSentencesGeneration> getIndicativeSentencesGeneration
(Class<?> testClass) Finds theIndicativeSentencesGeneration
annotation that is present, meta-present or if it doesn't find it, then search for the enclosing parent classes, if no annotation is found returns empty.private String
getSentenceBeginning
(Class<?> testClass) private String
getSentenceSeparator
(Class<?> testClass) Gets the separator forIndicativeSentencesGeneration
when extracting the annotation fromIndicativeSentencesGeneration
, if it doesn't find it, then search for the parent classes, if no separator is found use @code{", "} by default.
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
IndicativeSentences
public IndicativeSentences()
-
-
Method Details
-
generateDisplayNameForClass
Description copied from interface:DisplayNameGenerator
Generate a display name for the given top-level orstatic
nested test class.- Specified by:
generateDisplayNameForClass
in interfaceDisplayNameGenerator
- Parameters:
testClass
- the class to generate a name for; nevernull
- Returns:
- the display name for the class; never
null
or blank
-
generateDisplayNameForNestedClass
Description copied from interface:DisplayNameGenerator
Generate a display name for the given@Nested
inner test class.- Specified by:
generateDisplayNameForNestedClass
in interfaceDisplayNameGenerator
- Parameters:
nestedClass
- the class to generate a name for; nevernull
- Returns:
- the display name for the nested class; never
null
or blank
-
generateDisplayNameForMethod
Description copied from interface:DisplayNameGenerator
Generate a display name for the given method.- Specified by:
generateDisplayNameForMethod
in interfaceDisplayNameGenerator
- Parameters:
testClass
- the class the test method is invoked on; nevernull
testMethod
- method to generate a display name for; nevernull
- Returns:
- the display name for the test; never
null
or blank
-
getSentenceBeginning
-
getSentenceSeparator
Gets the separator forIndicativeSentencesGeneration
when extracting the annotation fromIndicativeSentencesGeneration
, if it doesn't find it, then search for the parent classes, if no separator is found use @code{", "} by default.- Parameters:
testClass
- Class to get Indicative sentence annotation separator either custom or default- Returns:
- the indicative sentence separator
-
getGeneratorForIndicativeSentence
Gets the generator forIndicativeSentencesGeneration
when extracting the annotation fromIndicativeSentencesGeneration
, if it doesn't find it, then search for the parent classes, if no generator value is found useDisplayNameGenerator.Standard
by default.- Parameters:
testClass
- Class to get Indicative sentence generator either custom or default- Returns:
- the
DisplayNameGenerator
instance to use in indicative sentences generator
-
getIndicativeSentencesGeneration
private Optional<IndicativeSentencesGeneration> getIndicativeSentencesGeneration(Class<?> testClass) Finds theIndicativeSentencesGeneration
annotation that is present, meta-present or if it doesn't find it, then search for the enclosing parent classes, if no annotation is found returns empty.- Parameters:
testClass
- the test class to find theIndicativeSentencesGeneration
annotation- Returns:
- the optional annotation retrieved from the test class.
-