Top Constructors Methods
org.junit.jupiter.engine.descriptor

pack-priv Class DynamicExtensionContext

extends AbstractExtensionContext<DynamicNodeTestDescriptor>
Class Inheritance
Imports
java.lang.reflect.AnnotatedElement, .Method, java.util.Optional, org.junit.jupiter.api.TestInstance, org.junit.jupiter.api.extension.ExecutableInvoker, .ExtensionContext, .TestInstances, org.junit.jupiter.engine.config.JupiterConfiguration, org.junit.platform.engine.EngineExecutionListener, org.junit.platform.engine.support.hierarchical.Node

Constructor Summary

AccessConstructor and Description
pack-priv
DynamicExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener, DynamicNodeTestDescriptor testDescriptor, JupiterConfiguration configuration, ExecutableInvoker executableInvoker)

Method Summary

Modifier and TypeMethod and Description
public Optional<AnnotatedElement>
getElement()

Implements org.junit.jupiter.api.extension.ExtensionContext.getElement.

Get the AnnotatedElement corresponding to the current extension context, if available.
public Optional<Throwable>
getExecutionException()

Implements org.junit.jupiter.api.extension.ExtensionContext.getExecutionException.

Get the exception that was thrown during execution of the test or container associated with this ExtensionContext, if available.
protected Node.ExecutionMode
public Optional<Class<?>>
getTestClass()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestClass.

Get the Class associated with the current test or container, if available.
public Optional<Object>
getTestInstance()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestInstance.

Get the test instance associated with the current test or container, if available.
public Optional<TestInstance.Lifecycle>
getTestInstanceLifecycle()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestInstanceLifecycle.

Get the Lifecycle of the test instance associated with the current test or container, if available.
public Optional<TestInstances>
getTestInstances()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestInstances.

Get the test instances associated with the current test or container, if available.
public Optional<Method>
getTestMethod()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestMethod.

Get the Method associated with the current test, if available.
Inherited from org.junit.jupiter.engine.descriptor.AbstractExtensionContext:
closegetConfigurationParametergetConfigurationParametergetDisplayNamegetExecutableInvokergetExecutionModegetParentgetRootgetStoregetTagsgetTestDescriptorgetUniqueIdpublishReportEntry

Constructor Detail

DynamicExtensionContextback to summary
pack-priv DynamicExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener, DynamicNodeTestDescriptor testDescriptor, JupiterConfiguration configuration, ExecutableInvoker executableInvoker)

Method Detail

getElementback to summary
public Optional<AnnotatedElement> getElement()

Implements org.junit.jupiter.api.extension.ExtensionContext.getElement.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getElement.

Get the AnnotatedElement 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 or Method 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:Optional<AnnotatedElement>

an Optional containing the AnnotatedElement; never null but potentially empty

Annotations
@Override
getExecutionExceptionback to summary
public Optional<Throwable> getExecutionException()

Implements org.junit.jupiter.api.extension.ExtensionContext.getExecutionException.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getExecutionException.

Get the exception that was thrown during execution of the test or container associated with this ExtensionContext, 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-level Extension. Similarly, if this ExtensionContext represents a test class, the execution exception returned by this method can be any exception thrown in a @BeforeAll or AfterAll method or a class-level Extension.

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:Optional<Throwable>

an Optional containing the exception thrown; never null but potentially empty if test execution has not (yet) resulted in an exception

Annotations
@Override
getPlatformExecutionModeback to summary
protected Node.ExecutionMode getPlatformExecutionMode()

Implements abstract org.junit.jupiter.engine.descriptor.AbstractExtensionContext.getPlatformExecutionMode.

Annotations
@Override
getTestClassback to summary
public Optional<Class<?>> getTestClass()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestClass.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getTestClass.

Get the Class associated with the current test or container, if available.

Returns:Optional<Class<?>>

an Optional containing the class; never null but potentially empty

Annotations
@Override
getTestInstanceback to summary
public Optional<Object> getTestInstance()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestInstance.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getTestInstance.

Get the test instance associated with the current test or container, if available.

Returns:Optional<Object>

an Optional containing the test instance; never null but potentially empty

Annotations
@Override
getTestInstanceLifecycleback to summary
public Optional<TestInstance.Lifecycle> getTestInstanceLifecycle()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestInstanceLifecycle.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getTestInstanceLifecycle.

Get the Lifecycle of the test instance associated with the current test or container, if available.

Returns:Optional<TestInstance.Lifecycle>

an Optional containing the test instance Lifecycle; never null but potentially empty

Annotations
@Override
getTestInstancesback to summary
public Optional<TestInstances> getTestInstances()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestInstances.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getTestInstances.

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:Optional<TestInstances>

an Optional containing the test instances; never null but potentially empty

Annotations
@Override
getTestMethodback to summary
public Optional<Method> getTestMethod()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTestMethod.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getTestMethod.

Get the Method associated with the current test, if available.

Returns:Optional<Method>

an Optional containing the method; never null but potentially empty

Annotations
@Override