You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While switching the default @NestedTestConfiguration mode to INHERIT in fbb3c5c, 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
Ensure that MetaAnnotationUtils.lookUpEnclosingConfiguration() does not search on enclosing classes for nested interfaces.
The text was updated successfully, but these errors were encountered:
Status Quo
While switching the default
@NestedTestConfiguration
mode toINHERIT
in fbb3c5c, 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 inMetaAnnotationUtils.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 theMergedAnnotations
API. To fix this bug, a custom annotation search algorithm will have to be used, analogous to other search algorithms recently introduced inMetaAnnotationUtils
.Deliverables
MetaAnnotationUtils.lookUpEnclosingConfiguration()
does not search on enclosing classes for nested interfaces.The text was updated successfully, but these errors were encountered: