Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Favor more locally declared composed annotations over inherited annotations in the TestContext framework [SPR-12749] #17346
Specific case: a test class is annotated with a meta annotation that itself is annotated with a TestExecutionListeners annotation, and the test class also extends a parent class annotated with a TestExecutionListeners annotation (say AbstractJunit4SpringContextTests).
In this case, MetaAnnotationUtils.findAnnotationDescriptor returns a AnnotationDescriptor class that is correct on all of its fields, except for getAnnotationAttributes(), which is incorrectly returning the attributes of the TestExecutionListeners from the parent class, rather than the meta annotation, which is incorrect based on the description of MetaAnnotationUtils.findAnnotationDescriptor:
The net result being the test framework does not pick up my declared TestExecutionListeners from the meta annotation any time a parent of the Test class also declares TestExecutionListeners. I added a spring-framework-issues reproducible project to demonstrate the issue.
Reference URL: spring-projects/spring-framework-issues#92
Sam Brannen commented
Although #16221 will cover such support in a generic fashion across the framework, I have already implemented a fix that is local to the