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 java.lang.Object implements DisplayNameGeneratorDisplayNameGeneratorthat 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
@IndicativeSentencesGenerationannotation.- 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 Modifier and Type Field Description (package private) static DisplayNameGeneratorINSTANCE
-
Constructor Summary
Constructors Constructor Description IndicativeSentences()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.Optional<DisplayNameGeneration>findDisplayNameGeneration(java.lang.Class<?> testClass)Find the firstDisplayNameGenerationannotation that is either directly present, meta-present, or indirectly present on the suppliedtestClassor on an enclosing class.private static java.util.Optional<IndicativeSentencesGeneration>findIndicativeSentencesGeneration(java.lang.Class<?> testClass)Find the firstIndicativeSentencesGenerationannotation that is either directly present, meta-present, or indirectly present on the suppliedtestClassor on an enclosing class.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.private static java.lang.StringgetFragmentSeparator(java.lang.Class<?> testClass)Get the sentence fragment separator.private static DisplayNameGeneratorgetGeneratorFor(java.lang.Class<?> testClass)Get the display name generator to use for the supplied test class.private java.lang.StringgetSentenceBeginning(java.lang.Class<?> testClass)private static java.util.function.Predicate<java.lang.Class<?>>not(java.lang.Class<?> clazz)
-
-
-
Field Detail
-
INSTANCE
static final DisplayNameGenerator INSTANCE
-
-
Method Detail
-
generateDisplayNameForClass
public java.lang.String generateDisplayNameForClass(java.lang.Class<?> testClass)
Description copied from interface:DisplayNameGeneratorGenerate a display name for the given top-level orstaticnested test class.- Specified by:
generateDisplayNameForClassin interfaceDisplayNameGenerator- Parameters:
testClass- the class to generate a name for; nevernull- Returns:
- the display name for the class; never
nullor blank
-
generateDisplayNameForNestedClass
public java.lang.String generateDisplayNameForNestedClass(java.lang.Class<?> nestedClass)
Description copied from interface:DisplayNameGeneratorGenerate a display name for the given@Nestedinner test class.- Specified by:
generateDisplayNameForNestedClassin interfaceDisplayNameGenerator- Parameters:
nestedClass- the class to generate a name for; nevernull- Returns:
- the display name for the nested class; never
nullor blank
-
generateDisplayNameForMethod
public java.lang.String generateDisplayNameForMethod(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)Description copied from interface:DisplayNameGeneratorGenerate a display name for the given method.- Specified by:
generateDisplayNameForMethodin interfaceDisplayNameGenerator- 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
-
getSentenceBeginning
private java.lang.String getSentenceBeginning(java.lang.Class<?> testClass)
-
getFragmentSeparator
private static java.lang.String getFragmentSeparator(java.lang.Class<?> testClass)
Get the sentence fragment separator.If
@IndicativeSentencesGenerationis present (searching enclosing classes if not found locally), the configuredseparatorwill be used. Otherwise,IndicativeSentencesGeneration.DEFAULT_SEPARATORwill be used.- Parameters:
testClass- the test class to search on for@IndicativeSentencesGeneration- Returns:
- the sentence fragment separator
-
getGeneratorFor
private static DisplayNameGenerator getGeneratorFor(java.lang.Class<?> testClass)
Get the display name generator to use for the supplied test class.If
@IndicativeSentencesGenerationis present (searching enclosing classes if not found locally), the configuredgeneratorwill be used. Otherwise,IndicativeSentencesGeneration.DEFAULT_GENERATORwill be used.- Parameters:
testClass- the test class to search on for@IndicativeSentencesGeneration- Returns:
- the
DisplayNameGeneratorinstance to use
-
findDisplayNameGeneration
private static java.util.Optional<DisplayNameGeneration> findDisplayNameGeneration(java.lang.Class<?> testClass)
Find the firstDisplayNameGenerationannotation that is either directly present, meta-present, or indirectly present on the suppliedtestClassor on an enclosing class.- Parameters:
testClass- the test class on which to find the annotation; nevernull- Returns:
- an
Optionalcontaining the annotation, potentially empty if not found
-
findIndicativeSentencesGeneration
private static java.util.Optional<IndicativeSentencesGeneration> findIndicativeSentencesGeneration(java.lang.Class<?> testClass)
Find the firstIndicativeSentencesGenerationannotation that is either directly present, meta-present, or indirectly present on the suppliedtestClassor on an enclosing class.- Parameters:
testClass- the test class on which to find the annotation; nevernull- Returns:
- an
Optionalcontaining the annotation, potentially empty if not found
-
not
private static java.util.function.Predicate<java.lang.Class<?>> not(java.lang.Class<?> clazz)
-
-