private static class TestInfoParameterResolver.DefaultTestInfo extends java.lang.Object implements TestInfo
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
displayName |
private java.util.Set<java.lang.String> |
tags |
private java.util.Optional<java.lang.Class<?>> |
testClass |
private java.util.Optional<java.lang.reflect.Method> |
testMethod |
Constructor and Description |
---|
DefaultTestInfo(ExtensionContext extensionContext) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDisplayName()
Get the display name of the current test or container.
|
java.util.Set<java.lang.String> |
getTags()
Get the set of all tags for the current test or container.
|
java.util.Optional<java.lang.Class<?>> |
getTestClass()
Get the
Class associated with the current test or container, if available. |
java.util.Optional<java.lang.reflect.Method> |
getTestMethod()
Get the
Method associated with the current test, if available. |
private static java.lang.Object |
nullSafeGet(java.util.Optional<?> optional) |
java.lang.String |
toString() |
private final java.lang.String displayName
private final java.util.Set<java.lang.String> tags
private final java.util.Optional<java.lang.Class<?>> testClass
private final java.util.Optional<java.lang.reflect.Method> testMethod
DefaultTestInfo(ExtensionContext extensionContext)
public java.lang.String getDisplayName()
TestInfo
The display name is either a default name or a custom name configured
via @DisplayName
.
If the context in which TestInfo
is used is at the container
level, the default display name is generated based on the name of the
test class. For top-level and @Nested
test classes, the
default display name is the simple name
of the class. For static
nested test classes, the default display
name is the default display name for the enclosing class concatenated with
the simple name of the static
nested class, separated by a dollar sign ($
). For example, the
default display names for the following test classes are
TopLevelTests
, NestedTests
, and TopLevelTests$StaticTests
.
class TopLevelTests { @Nested class NestedTests {} static class StaticTests {} }
If the context in which TestInfo
is used is at the test level,
the default display name is the name of the test method concatenated with
a comma-separated list of simple names
of the parameter types in parentheses. For example, the default display
name for the following test method is testUser(TestInfo, User)
.
@Test void testUser(TestInfo testInfo, @Mock User user) {}
Note that display names are typically used for test reporting in IDEs and build tools and may contain spaces, special characters, and even emoji.
getDisplayName
in interface TestInfo
null
or blankpublic java.util.Set<java.lang.String> getTags()
TestInfo
Tags may be declared directly on the test element or inherited from an outer context.
public java.util.Optional<java.lang.Class<?>> getTestClass()
TestInfo
Class
associated with the current test or container, if available.getTestClass
in interface TestInfo
public java.util.Optional<java.lang.reflect.Method> getTestMethod()
TestInfo
Method
associated with the current test, if available.getTestMethod
in interface TestInfo
public java.lang.String toString()
toString
in class java.lang.Object
private static java.lang.Object nullSafeGet(java.util.Optional<?> optional)