-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Milestone
Description
Due to the checks in ExtensionUtils.IsNonStaticExtensionField and ExtensionUtils.IsStaticExtensionField it is not currently possible to use @RegisterExtension on fields that do not implement Extension. Furthermore, no warning or error is produced telling the developer that the extension is not active.
I wonder if this restriction could be relaxed, and the @RegisterExtension annotation alone be used as the trigger. If the actual field instance does not implement Extension then an error could be raised.
The specific driver for this issue is to allow a @RegisterExtension class that does not present JUnit specific APIs to the user. i.e.:
public class UserFacingApi {
// .. API methods the user will want
}
public class ExtensionClass extends UserFacingApi implement Extension... {
// .. JUnit methods that the user should not call
}@RegisterExtension
private UserFacingApi userFacing = new ExtensionClass();(see spring-projects/spring-boot#17029 for a real use-case)