Class JupiterEngineExtensionContext
- All Implemented Interfaces:
AutoCloseable
,ExtensionContext
- Since:
- 5.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.ExtensionContext
ExtensionContext.Namespace, ExtensionContext.Store
-
Constructor Summary
ConstructorsConstructorDescriptionJupiterEngineExtensionContext
(EngineExecutionListener engineExecutionListener, JupiterEngineDescriptor testDescriptor, JupiterConfiguration configuration, ExecutableInvoker executableInvoker) -
Method Summary
Modifier and TypeMethodDescriptionGet theAnnotatedElement
corresponding to the current extension context, if available.Get the exception that was thrown during execution of the test or container associated with thisExtensionContext
, if available.protected Node.ExecutionMode
Get theClass
associated with the current test or container, if available.Get the test instance associated with the current test or container, if available.Get theTestInstance.Lifecycle
of the test instance associated with the current test or container, if available.Get the test instances associated with the current test or container, if available.Get theMethod
associated with the current test, if available.Methods inherited from class org.junit.jupiter.engine.descriptor.AbstractExtensionContext
close, getConfigurationParameter, getConfigurationParameter, getDisplayName, getExecutableInvoker, getExecutionMode, getParent, getRoot, getStore, getTags, getTestDescriptor, getUniqueId, publishReportEntry
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.junit.jupiter.api.extension.ExtensionContext
getRequiredTestClass, getRequiredTestInstance, getRequiredTestInstances, getRequiredTestMethod, publishReportEntry, publishReportEntry
-
Constructor Details
-
JupiterEngineExtensionContext
JupiterEngineExtensionContext(EngineExecutionListener engineExecutionListener, JupiterEngineDescriptor testDescriptor, JupiterConfiguration configuration, ExecutableInvoker executableInvoker)
-
-
Method Details
-
getElement
Description copied from interface:ExtensionContext
Get theAnnotatedElement
corresponding to the current extension context, if available.For example, if the current extension context encapsulates a test class, test method, test factory method, or test template method, the annotated element will be the corresponding
Class
orMethod
reference.Favor this method over more specific methods whenever the
AnnotatedElement
API suits the task at hand — for example, when looking up annotations regardless of concrete element type.- Returns:
- an
Optional
containing theAnnotatedElement
; nevernull
but potentially empty - See Also:
-
getTestClass
Description copied from interface:ExtensionContext
Get theClass
associated with the current test or container, if available.- Returns:
- an
Optional
containing the class; nevernull
but potentially empty - See Also:
-
getTestInstanceLifecycle
Description copied from interface:ExtensionContext
Get theTestInstance.Lifecycle
of the test instance associated with the current test or container, if available.- Returns:
- an
Optional
containing the test instanceLifecycle
; nevernull
but potentially empty - See Also:
-
getTestInstance
Description copied from interface:ExtensionContext
Get the test instance associated with the current test or container, if available.- Returns:
- an
Optional
containing the test instance; nevernull
but potentially empty - See Also:
-
getTestInstances
Description copied from interface:ExtensionContext
Get the test instances associated with the current test or container, if available.While top-level tests only have a single test instance, nested tests have one additional instance for each enclosing test class.
- Returns:
- an
Optional
containing the test instances; nevernull
but potentially empty - See Also:
-
getTestMethod
Description copied from interface:ExtensionContext
Get theMethod
associated with the current test, if available.- Returns:
- an
Optional
containing the method; nevernull
but potentially empty - See Also:
-
getExecutionException
Description copied from interface:ExtensionContext
Get the exception that was thrown during execution of the test or container associated with thisExtensionContext
, if available.This method is typically used for logging and tracing purposes. If you wish to actually handle an exception thrown during test execution, implement the
TestExecutionExceptionHandler
API.Unlike the exception passed to a
TestExecutionExceptionHandler
, an execution exception returned by this method can be any exception thrown during the invocation of a@Test
method, its surrounding@BeforeEach
and@AfterEach
methods, or a test-levelExtension
. Similarly, if thisExtensionContext
represents a test class, the execution exception returned by this method can be any exception thrown in a@BeforeAll
orAfterAll
method or a class-levelExtension
.Note, however, that this method will never return an exception swallowed by a
TestExecutionExceptionHandler
. Furthermore, if multiple exceptions have been thrown during test execution, the exception returned by this method will be the first such exception with all additional exceptions suppressed in the first one.- Returns:
- an
Optional
containing the exception thrown; nevernull
but potentially empty if test execution has not (yet) resulted in an exception
-
getPlatformExecutionMode
- Specified by:
getPlatformExecutionMode
in classAbstractExtensionContext<JupiterEngineDescriptor>
-