Closed
Description
openedon Oct 7, 2024
Since version 5.11.x, if a field is meta-annotated with multiple @ExtendWith
annotations, JUnit fails to detect them.
The problem seems to be in ExtensionUtils#streamExtensionFilteringFields
, which does not take into account repeatable annotations:
Steps to reproduce
-
Meta-annotate some test class fields with multiple
@ExtendWith
annotations:@Retention(RetentionPolicy.RUNTIME) @ExtendWith(Extension1.class) @ExtendWith(Extension2.class) public @interface ComposedAnnotation {}
public class TestClassWithFields { @ComposedAnnotation private static int staticFieldMetaAnnotatedTwice; @ComposedAnnotation private int instanceFieldMetaAnnotatedTwice; }
-
Run the following test cases:
class ExtensionsUtilsTests { @Test void discoverExtensionsOnStaticFields() { ExtensionRegistrar registrar = mock(); ExtensionUtils.registerExtensionsFromStaticFields(registrar, ClassWithFields.class); verify(registrar).registerExtension(Extension1.class); verify(registrar).registerExtension(Extension2.class); } @Test void discoverExtensionsOnInstanceFields() { ExtensionRegistrar registrar = mock(); ExtensionUtils.registerExtensionsFromInstanceFields(registrar, ClassWithFields.class); verify(registrar).registerExtension(Extension1.class); verify(registrar).registerExtension(Extension2.class); } }
Context
- Used versions (Jupiter/Vintage/Platform): Jupiter 5.11.1 / Platform 1.11.1
- Build Tool/IDE: Maven
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment