Description
openedon Sep 10, 2016
Background
This issue addresses some of the topics discussed in #112.
Status Quo
It is currently possible to register extensions declaratively via @ExtendWith
on types and methods, and #497 will support programmatic extension registration via fields. However...
- Developers cannot alter the order of registered extensions.
- Developers cannot remove a registered extension.
- Developers cannot insert an extension into the list of registered extensions -- for example, at the front or somewhere in the middle.
Rationale
In order to avoid the introduction of an overly complex declarative model for sorting, appending, prepending, inserting, and removing extensions, we have opted for a programmatic means to achieve all of the above. Providing a programmatic means to achieve these goals frees developers to manage registered extensions as they see fit without any unnecessary restrictions imposed on them by the framework itself.
Considerations
Such a mechanism could itself be an Extension
registered declaratively via @ExtendWith
; however, the current thinking in the team is that there should be one and only one such component registered at any given time. Since this is such a special case which affects all extensions which have been registered declaratively, it is therefore considered best to introduce a new declarative mechanism for registering this single component. Similarly, the API for such a component should therefore not extend Extension
since doing so would allow users to incorrectly register it via @ExtendWith
(in which case it would simply be silently ignored).
Proposal
- Introduce an
ExtensionManager
API that receives a list of all registered extensions as input and returns a list of extensions. - Introduce a
@ManageExtensionsWith
annotation that allows the user to declare a single class reference for an implementation ofExtensionManager
.
Related Issues
- Provide mechanism to order the sequence of tests #13
- Support @ExtendWith on fields #416
- Support programmatic extension registration via fields #497
- Support declarative extension registration on fields and parameters #864
- Introduce declarative mechanism for ordering extensions registered via @RegisterExtension #1707
Deliverables
- Introduce a mechanism for programmatic extension management.