Class DisplayNameGenerator.IndicativeSentences
- All Implemented Interfaces:
DisplayNameGenerator
- Enclosing interface:
DisplayNameGenerator
DisplayNameGenerator
that generates complete sentences.
This generator generates display names that build up complete sentences
by concatenating the names of the test and the enclosing classes. The
sentence fragments are concatenated using a separator. The separator and
the display name generator for individual sentence fragments can be configured
via the @IndicativeSentencesGeneration
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 TypeMethodDescriptionprivate static Optional
<DisplayNameGeneration> findDisplayNameGeneration
(Class<?> testClass) Find the firstDisplayNameGeneration
annotation that is either directly present, meta-present, or indirectly present on the suppliedtestClass
or on an enclosing class.private static Optional
<IndicativeSentencesGeneration> findIndicativeSentencesGeneration
(Class<?> testClass) Find the firstIndicativeSentencesGeneration
annotation that is either directly present, meta-present, or indirectly present on the suppliedtestClass
or on an enclosing class.generateDisplayNameForClass
(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 static String
getFragmentSeparator
(Class<?> testClass) Get the sentence fragment separator.private static DisplayNameGenerator
getGeneratorFor
(Class<?> testClass) Get the display name generator to use for the supplied test class.private String
getSentenceBeginning
(Class<?> testClass)
-
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
-
getFragmentSeparator
Get the sentence fragment separator.If
@IndicativeSentencesGeneration
is present (searching enclosing classes if not found locally), the configuredseparator
will be used. Otherwise,IndicativeSentencesGeneration.DEFAULT_SEPARATOR
will be used.- Parameters:
testClass
- the test class to search on for@IndicativeSentencesGeneration
- Returns:
- the sentence fragment separator
-
getGeneratorFor
Get the display name generator to use for the supplied test class.If
@IndicativeSentencesGeneration
is present (searching enclosing classes if not found locally), the configuredgenerator
will be used. Otherwise,IndicativeSentencesGeneration.DEFAULT_GENERATOR
will be used.- Parameters:
testClass
- the test class to search on for@IndicativeSentencesGeneration
- Returns:
- the
DisplayNameGenerator
instance to use
-
findDisplayNameGeneration
Find the firstDisplayNameGeneration
annotation that is either directly present, meta-present, or indirectly present on the suppliedtestClass
or on an enclosing class.- Parameters:
testClass
- the test class on which to find the annotation; nevernull
- Returns:
- an
Optional
containing the annotation, potentially empty if not found
-
findIndicativeSentencesGeneration
private static Optional<IndicativeSentencesGeneration> findIndicativeSentencesGeneration(Class<?> testClass) Find the firstIndicativeSentencesGeneration
annotation that is either directly present, meta-present, or indirectly present on the suppliedtestClass
or on an enclosing class.- Parameters:
testClass
- the test class on which to find the annotation; nevernull
- Returns:
- an
Optional
containing the annotation, potentially empty if not found
-
not
-