Top Description Methods
org.junit.jupiter.engine.extension

public Interface ExtensionRegistrar

Known Direct Implementers
org.junit.jupiter.engine.extension.MutableExtensionRegistry
Annotations
@API
status:INTERNAL
since:5.5
Static Imports
org.apiguardian.api.API.Status.INTERNAL

An ExtensionRegistrar is used to register extensions.
Since
5.5

Method Summary

Modifier and TypeMethod and Description
public void
initializeExtensions(Class<?>
the test class for which the extensions are initialized; never null
testClass
,
Object
the test instance to be used to initialize the extensions; never null
testInstance
)

Initialize all registered extensions for the supplied testClass using the supplied testInstance.

public void
registerExtension(Class<? extends Extension>
the type of extension to register
extensionType
)

Instantiate an extension of the given type using its default constructor and register it in the registry.

public void
registerExtension(Extension
the extension to register; never null
extension
,
Object
the source of the extension; never null
source
)

Register the supplied Extension, without checking if an extension of that type has already been registered.

public void
registerSyntheticExtension(Extension
the extension to register; never null
extension
,
Object
the source of the extension; never null
source
)

Register the supplied Extension as a synthetic extension, without checking if an extension of that type has already been registered.

public void
registerUninitializedExtension(Class<?>
the test class for which the extension is registered; never null
testClass
,
Field
the source of the extension; never null
source
,
Function<Object, ? extends Extension>
the initializer function to be used to create the extension; never null
initializer
)

Register an uninitialized extension for the supplied testClass to be initialized using the supplied initializer when an instance of the test class is created.

Method Detail

initializeExtensionsback to summary
public void initializeExtensions(Class<?> testClass, Object testInstance)

Initialize all registered extensions for the supplied testClass using the supplied testInstance.

Parameters
testClass:Class<?>

the test class for which the extensions are initialized; never null

testInstance:Object

the test instance to be used to initialize the extensions; never null

registerExtensionback to summary
public void registerExtension(Class<? extends Extension> extensionType)

Instantiate an extension of the given type using its default constructor and register it in the registry.

A new Extension should not be registered if an extension of the given type already exists in the registry or a parent registry.

Parameters
extensionType:Class<? extends Extension>

the type of extension to register

Since
5.8
registerExtensionback to summary
public void registerExtension(Extension extension, Object source)

Register the supplied Extension, without checking if an extension of that type has already been registered.

Semantics for Source

If an extension is registered declaratively via @ExtendWith, the source and the extension should be the same object. However, if an extension is registered programmatically via @RegisterExtension, the source object should be the java.lang.reflect.Field that is annotated with @RegisterExtension. Similarly, if an extension is registered programmatically as a lambda expression or method reference, the source object should be the underlying java.lang.reflect.Method that implements the extension API.

Parameters
extension:Extension

the extension to register; never null

source:Object

the source of the extension; never null

registerSyntheticExtensionback to summary
public void registerSyntheticExtension(Extension extension, Object source)

Register the supplied Extension as a synthetic extension, without checking if an extension of that type has already been registered.

Parameters
extension:Extension

the extension to register; never null

source:Object

the source of the extension; never null

Since
5.8
See Also
registerExtension(Extension, Object)
registerUninitializedExtensionback to summary
public void registerUninitializedExtension(Class<?> testClass, Field source, Function<Object, ? extends Extension> initializer)

Register an uninitialized extension for the supplied testClass to be initialized using the supplied initializer when an instance of the test class is created.

Uninitialized extensions are typically registered for fields annotated with @RegisterExtension that cannot be initialized until an instance of the test class is created. Until they are initialized, such extensions are not available for use.

Parameters
testClass:Class<?>

the test class for which the extension is registered; never null

source:Field

the source of the extension; never null

initializer:Function<Object, ? extends Extension>

the initializer function to be used to create the extension; never null