@API(status=STABLE,
since="5.10")
public static class DisplayNameGenerator.IndicativeSentences
extends java.lang.Object
implements 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.
DisplayNameGenerator.IndicativeSentences, DisplayNameGenerator.ReplaceUnderscores, DisplayNameGenerator.Simple, DisplayNameGenerator.Standard| Modifier and Type | Field and Description |
|---|---|
(package private) static DisplayNameGenerator |
INSTANCE |
DEFAULT_GENERATOR_PROPERTY_NAME| Constructor and Description |
|---|
IndicativeSentences() |
| Modifier and Type | Method and Description |
|---|---|
private static java.util.Optional<DisplayNameGeneration> |
findDisplayNameGeneration(java.lang.Class<?> testClass)
Find the first
DisplayNameGeneration annotation that is either
directly present, meta-present, or indirectly present
on the supplied testClass or on an enclosing class. |
private static java.util.Optional<IndicativeSentencesGeneration> |
findIndicativeSentencesGeneration(java.lang.Class<?> testClass)
Find the first
IndicativeSentencesGeneration annotation that is either
directly present, meta-present, or indirectly present
on the supplied testClass or on an enclosing class. |
java.lang.String |
generateDisplayNameForClass(java.lang.Class<?> testClass)
Generate a display name for the given top-level or
static 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. |
private static java.lang.String |
getFragmentSeparator(java.lang.Class<?> testClass)
Get the sentence fragment separator.
|
private static DisplayNameGenerator |
getGeneratorFor(java.lang.Class<?> testClass)
Get the display name generator to use for the supplied test class.
|
private java.lang.String |
getSentenceBeginning(java.lang.Class<?> testClass) |
private static java.util.function.Predicate<java.lang.Class<?>> |
not(java.lang.Class<?> clazz) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDisplayNameGenerator, parameterTypesAsStringstatic final DisplayNameGenerator INSTANCE
public java.lang.String generateDisplayNameForClass(java.lang.Class<?> testClass)
DisplayNameGeneratorstatic nested test class.
If it returns null, the default display name generator will be used instead.
generateDisplayNameForClass in interface DisplayNameGeneratortestClass - the class to generate a name for; never nullpublic java.lang.String generateDisplayNameForNestedClass(java.lang.Class<?> nestedClass)
DisplayNameGenerator@Nested inner test class.
If it returns null, the default display name generator will be used instead.
generateDisplayNameForNestedClass in interface DisplayNameGeneratornestedClass - the class to generate a name for; never nullpublic java.lang.String generateDisplayNameForMethod(java.lang.Class<?> testClass,
java.lang.reflect.Method testMethod)
DisplayNameGeneratorIf it returns null, the default display name generator will be used instead.
generateDisplayNameForMethod in interface DisplayNameGeneratortestClass - the class the test method is invoked on; never nulltestMethod - method to generate a display name for; never nullprivate java.lang.String getSentenceBeginning(java.lang.Class<?> testClass)
private static java.lang.String getFragmentSeparator(java.lang.Class<?> testClass)
If @IndicativeSentencesGeneration
is present (searching enclosing classes if not found locally), the
configured separator
will be used. Otherwise, IndicativeSentencesGeneration.DEFAULT_SEPARATOR
will be used.
testClass - the test class to search on for @IndicativeSentencesGenerationprivate static DisplayNameGenerator getGeneratorFor(java.lang.Class<?> testClass)
If @IndicativeSentencesGeneration
is present (searching enclosing classes if not found locally), the
configured generator
will be used. Otherwise, IndicativeSentencesGeneration.DEFAULT_GENERATOR
will be used.
testClass - the test class to search on for @IndicativeSentencesGenerationDisplayNameGenerator instance to useprivate static java.util.Optional<DisplayNameGeneration> findDisplayNameGeneration(java.lang.Class<?> testClass)
DisplayNameGeneration annotation that is either
directly present, meta-present, or indirectly present
on the supplied testClass or on an enclosing class.testClass - the test class on which to find the annotation; never nullOptional containing the annotation, potentially empty if not foundprivate static java.util.Optional<IndicativeSentencesGeneration> findIndicativeSentencesGeneration(java.lang.Class<?> testClass)
IndicativeSentencesGeneration annotation that is either
directly present, meta-present, or indirectly present
on the supplied testClass or on an enclosing class.testClass - the test class on which to find the annotation; never nullOptional containing the annotation, potentially empty if not foundprivate static java.util.function.Predicate<java.lang.Class<?>> not(java.lang.Class<?> clazz)