Class TestInfoParameterResolver.DefaultTestInfo
- java.lang.Object
-
- org.junit.jupiter.engine.extension.TestInfoParameterResolver.DefaultTestInfo
-
- All Implemented Interfaces:
TestInfo
- Enclosing class:
- TestInfoParameterResolver
private static class TestInfoParameterResolver.DefaultTestInfo extends java.lang.Object implements TestInfo
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringdisplayNameprivate java.util.Set<java.lang.String>tagsprivate java.util.Optional<java.lang.Class<?>>testClassprivate java.util.Optional<java.lang.reflect.Method>testMethod
-
Constructor Summary
Constructors Constructor Description DefaultTestInfo(ExtensionContext extensionContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetDisplayName()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 theClassassociated with the current test or container, if available.java.util.Optional<java.lang.reflect.Method>getTestMethod()Get theMethodassociated with the current test or container, if available.private static java.lang.ObjectnullSafeGet(java.util.Optional<?> optional)java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultTestInfo
DefaultTestInfo(ExtensionContext extensionContext)
-
-
Method Detail
-
getDisplayName
public java.lang.String getDisplayName()
Description copied from interface:TestInfoGet the display name of the current test or container.The display name is either a default name or a custom name configured via
@DisplayName.Default Display Names
If the context in which
TestInfois used is at the container level, the default display name is generated based on the name of the test class. For top-level and@Nestedtest classes, the default display name is the simple name of the class. Forstaticnested test classes, the default display name is the default display name for the enclosing class concatenated with the simple name of thestaticnested class, separated by a dollar sign ($). For example, the default display names for the following test classes areTopLevelTests,NestedTests, andTopLevelTests$StaticTests.class TopLevelTests { @Nested class NestedTests {} static class StaticTests {} }If the context in which
TestInfois 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 istestUser(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.
- Specified by:
getDisplayNamein interfaceTestInfo- Returns:
- the display name of the test or container; never
nullor blank
-
getTags
public java.util.Set<java.lang.String> getTags()
Description copied from interface:TestInfoGet the set of all tags for the current test or container.Tags may be declared directly on the test element or inherited from an outer context.
-
getTestClass
public java.util.Optional<java.lang.Class<?>> getTestClass()
Description copied from interface:TestInfoGet theClassassociated with the current test or container, if available.- Specified by:
getTestClassin interfaceTestInfo
-
getTestMethod
public java.util.Optional<java.lang.reflect.Method> getTestMethod()
Description copied from interface:TestInfoGet theMethodassociated with the current test or container, if available.- Specified by:
getTestMethodin interfaceTestInfo
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
nullSafeGet
private static java.lang.Object nullSafeGet(java.util.Optional<?> optional)
-
-