Status Quo
While switching the default @NestedTestConfiguration mode to INHERIT in fbb3c5cce73f07679afebbb39980fb971efb9f4f, I noticed that @NestedTestConfiguration was discovered on an enclosing class for a nested interface if a @Nested test class implemented the nested interface.
If the nested interface is local to a test class that is itself annotated with @NestedTestConfiguration, the search algorithm in MetaAnnotationUtils.lookUpEnclosingConfiguration() will find that annotation before declarations more local to the @Nested test class, and that annotation may be declared differently than a local declaration.
As a workaround, developers can redeclare @NestedTestConfiguration with the desired mode directly on a @Nested test class that implements such an interface, but that is cumbersome and error prone.
Analysis
This bug originates from use of SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES in the MergedAnnotations API. To fix this bug, a custom annotation search algorithm will have to be used, analogous to other search algorithms recently introduced in MetaAnnotationUtils.
Deliverables
- [x] Ensure that
MetaAnnotationUtils.lookUpEnclosingConfiguration()does not search on enclosing classes for nested interfaces.