Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@NestedTestConfiguration should not be discovered on enclosing class for nested interface #25917

Closed
1 task done
sbrannen opened this issue Oct 14, 2020 · 0 comments
Closed
1 task done
Assignees
Labels
in: test Issues in the test module type: bug A general bug
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Oct 14, 2020

Status Quo

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.
@sbrannen sbrannen added in: test Issues in the test module type: bug A general bug labels Oct 14, 2020
@sbrannen sbrannen added this to the 5.3 GA milestone Oct 14, 2020
@sbrannen sbrannen self-assigned this Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant