-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Fix @BootstrapWith
inheritance override issues
#26645
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
Conversation
@antoinemeyer Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@antoinemeyer Thank you for signing the Contributor License Agreement! |
712c5e8
to
6346908
Compare
Hi @antoinemeyer, Thanks for submitting the PR. I agree that we should improve the behavior here. Your PR addresses the exact use case you have described; however, it allows a directly present For example, given the following ... @BootstrapWith(BarBootstrapper.class)
@Retention(RetentionPolicy.RUNTIME)
@interface BootWithBar {}
@BootstrapWith(FooBootstrapper.class)
static class DirectBootstrapClass {}
@BootWithBar
static class InheritedDirectBootstrapAndLocalMetaBootstrapClass extends DirectBootstrapClass {} ... your proposal results in In summary, I think we should improve the situation for your specific use case, but we'll need to investigate how best to avoid the pitfall I outlined above. In light of that, I'm scheduling this for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have time to update this PR regarding the aforementioned pitfall, please let me know.
Otherwise, I will take a closer look in the 6.1.x
time frame.
@BootstrapWith
inheritance override issues
|
A
@BootstrapWith
annotation should be considered an override for@BootstrapWith
meta-annotations not only when the@BootstrapWith
annotation is directly present on the test class but also if it is present on the an ancestor of the test class.It is common to use a base test class such as:
Annotating this
BaseTest
with@BootstrapWith(XXX)
should not make tests extending this class fail withjava.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith
but instead properly use the@BootstrapWith
as an override of the bootstrap provided as a meta-annotation by@SpringBootTest
.