ExtensionContext encapsulates the context in which the
current test or container is being executed.
Extensions are provided an instance of
ExtensionContext to perform their work.
This interface is not intended to be implemented by clients.
Store, Namespace
| Modifier and Type | Class and Description |
|---|---|
| public static class | ExtensionContext.
A |
| public static interface | ExtensionContext.
|
| public static enum | ExtensionContext.
|
| Modifier and Type | Method and Description |
|---|---|
| public Optional | Returns: anOptional containing the value; never null
but potentially emptythe key to look up; never key)null or blankGet the configuration parameter stored under the specified |
| public <T> Optional | Returns: anOptional containing the value; never null
but potentially emptythe key to look up; never key, Function<? super String, ? extends @Nullable T> null or blankthe transformer to apply in case a value is found;
never transformer)nullGet and transform the configuration parameter stored under the specified
|
| public String | Returns: the display name of the test or container; nevernull or blankGet the display name for the current test or container. |
| public Optional | Returns: anOptional containing the AnnotatedElement;
never null but potentially emptyGet the |
| public List | Returns: an empty list if there is no class associated with the current test or container or when it is not nested; otherwise, a list containing the enclosing test classes in order from outermost to innermost; nevernullGet the enclosing test classes of the current test or container. |
| public ExecutableInvoker | getExecutableInvoker()
Get an |
| public Optional | Returns: anOptional containing the exception thrown; never
null but potentially empty if test execution has not (yet)
resulted in an exceptionGet the exception that was thrown during execution of the test or container
associated with this |
| public ExecutionMode | Returns: theExecutionMode of the test; never nullGet the |
| public Optional | Returns: anOptional containing the parent; never null but
potentially emptyGet the parent extension context, if available. |
| public default Class | Returns: the test class; nevernullGet the required |
| public default Object | Returns: the test instance; nevernullGet the required test instance associated with the current test or container. |
| public default TestInstances | Returns: the test instances; nevernullGet the required test instances associated with the current test or container. |
| public default Method | Returns: the test method; nevernullGet the required |
| public ExtensionContext | Returns: the root extension context; nevernull but potentially
this ExtensionContextGet the root |
| public ExtensionContext. | Returns: the store in which to put and get objects for other invocations working in the same namespace; nevernullthe namespaceNamespace to get the store for; never null |
| public ExtensionContext. | getStore(ExtensionContext.
Returns the store for supplied scope and namespace. |
| public Set | Returns: the set of tags for the test or container; nevernull but
potentially emptyGet the set of all tags for the current test or container. |
| public Optional | Returns: anOptional containing the class; never null but
potentially emptyGet the |
| public Optional | Returns: anOptional containing the test instance; never
null but potentially emptyGet the test instance associated with the current test or container, if available. |
| public Optional | Returns: anOptional containing the test instance Lifecycle;
never null but potentially emptyGet the |
| public Optional | Returns: anOptional containing the test instances; never
null but potentially emptyGet the test instances associated with the current test or container, if available. |
| public Optional | Returns: anOptional containing the method; never null but
potentially emptyGet the |
| public String | Returns: the unique ID of the test or container; nevernull or blankGet the unique ID of the current test or container. |
| public void | publishDirectory(String
the name of the directory to be published; never name, ThrowingConsumer<Path> null
or blank and must not contain any path separatorsthe action to be executed to write to the directory; never
action)nullPublish a directory with the supplied name written by the supplied action and attach it to the current test or container. |
| public default void | publishFile(String
the name of the file to be published; never name, MediaType null or
blank and must not contain any path separatorsthe media type of the file; never mediaType, ThrowingConsumer<Path> null; use
org.
if unknownthe action to be executed to write the file; never action)null
Deprecated
for removal since 5.14. Use
publishFile(String, MediaType, ThrowingConsumer)
instead.
Publish a file with the supplied name written by the supplied action and attach it to the current test or container. |
| public void | publishFile(String
the name of the file to be attached; never name, MediaType null or
blank and must not contain any path separatorsthe media type of the file; never mediaType, ThrowingConsumer<Path> null; use
MediaType#APPLICATION_OCTET_STREAM if unknownthe action to be executed to write the file; never action)nullPublish a file with the supplied name written by the supplied action and attach it to the current test or container. |
| public void | publishReportEntry(Map<String, String>
the key-value pairs to be published; never map)null;
keys and values within entries in the map also must not be
null or blankPublish a map of key-value pairs to be consumed by an
|
| public default void | publishReportEntry(String
the key of the published pair; never key, String null or blankthe value of the published pair; never value)null or blankPublish the specified key-value pair to be consumed by an
|
| public default void | publishReportEntry(String
the value to be published; never value)null or blankPublish the specified value to be consumed by an
|