Interface ExtensionRegistrar
- All Known Implementing Classes:
MutableExtensionRegistry
-
Method Summary
Modifier and TypeMethodDescriptionvoidinitializeExtensions(Class<?> testClass, Object testInstance) Initialize all registered extensions for the suppliedtestClassusing the suppliedtestInstance.voidregisterExtension(Class<? extends Extension> extensionType) Instantiate an extension of the given type using its default constructor and register it in the registry.voidregisterExtension(Extension extension, Object source) Register the suppliedExtension, without checking if an extension of that type has already been registered.voidregisterSyntheticExtension(Extension extension, Object source) Register the suppliedExtensionas a synthetic extension, without checking if an extension of that type has already been registered.voidregisterUninitializedExtension(Class<?> testClass, Field source, Function<Object, ? extends Extension> initializer) Register an uninitialized extension for the suppliedtestClassto be initialized using the suppliedinitializerwhen an instance of the test class is created.
-
Method Details
-
registerExtension
Instantiate an extension of the given type using its default constructor and register it in the registry.A new
Extensionshould not be registered if an extension of the given type already exists in the registry or a parent registry.- Parameters:
extensionType- the type of extension to register- Since:
- 5.8
-
registerExtension
Register the suppliedExtension, without checking if an extension of that type has already been registered.Semantics for Source
If an extension is registered declaratively via
@ExtendWith, thesourceand theextensionshould be the same object. However, if an extension is registered programmatically via@RegisterExtension, thesourceobject should be theFieldthat is annotated with@RegisterExtension. Similarly, if an extension is registered programmatically as a lambda expression or method reference, thesourceobject should be the underlyingMethodthat implements the extension API.- Parameters:
extension- the extension to register; nevernullsource- the source of the extension; nevernull
-
registerSyntheticExtension
Register the suppliedExtensionas a synthetic extension, without checking if an extension of that type has already been registered.- Parameters:
extension- the extension to register; nevernullsource- the source of the extension; nevernull- Since:
- 5.8
- See Also:
-
registerUninitializedExtension
void registerUninitializedExtension(Class<?> testClass, Field source, Function<Object, ? extends Extension> initializer) Register an uninitialized extension for the suppliedtestClassto be initialized using the suppliedinitializerwhen an instance of the test class is created.Uninitialized extensions are typically registered for fields annotated with
@RegisterExtensionthat 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- the test class for which the extension is registered; nevernullsource- the source of the extension; nevernullinitializer- the initializer function to be used to create the extension; nevernull
-
initializeExtensions
Initialize all registered extensions for the suppliedtestClassusing the suppliedtestInstance.- Parameters:
testClass- the test class for which the extensions are initialized; nevernulltestInstance- the test instance to be used to initialize the extensions; nevernull
-