-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Allow proper replacement of @SpringBootTest and extension of SpringBootTestContextBootstrapper #15077
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
Comments
I think in general
In general : Managing Application env before All these things can't really be achieved when one tries to @SpringBootApplication
@CustomFrameworkAnnotationsHere ( that runs the whole show...)
class Application{
} @SprintBootTest(class="Application.class")
@CantRealyDoMuchHereOnceContextIsFullyCreated :(
class ApplicationIT{
} The small tweek that can allow Note :
Currently, I successfully extended |
@erezwncare I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference. |
I wonder if we can create something similar to Another option might be to try and decompose It would certainly be nice if we could replace the existing |
@philwebb As part of my work on #14981 I already got rid of |
@philwebb thank you, will follow this format. Once the ExtBootstrap returns ExtContextLoader, I can override The total code written is not significant so I think some Spring tweaks can allow this to be easily accessible. The key ingredients are |
@dreis2211 Good point. It was a bit late for 2.1 but it would be very worthwhile revisiting this when we branch for 2.2. |
Adding to the request : Each time a code checks for the existence of SpringBootTest.class it renders this annotation as unextendable. If I want to have a custom @ExtSpringBootTest, I need to override that method. But its a private method... So now I have to override all method calling it : getInlinedProperties, loadContext. I am basically copy-pasting there code to my ExtSpringBootContextLoader just to support my custom boot chain. |
I was extending As I understand this issue didn't get enough priority but is there a workaround I can do for processing my custom annotations before the context initialization is done? |
Facing similar issues as the others. As a workaround, we will have to add In general I think the problem is that too many components are bound to this annotation type ( At first I saw so much magic happening and I did not like and tried to get rid of this |
Hello. |
Hi, I have arrived here hitting the same problem. |
The last version of
SpringBootTestContextBootstrapper
allows extension so users could create there own test bootstrappers while keeping Spring Test Context creation in line with default implementation.Since
@BootstrapWith
annotation can only be present once, any test that want to use the new bootstrap needs to replace , and can not use,@SpringBootTest
annotation.Once a new annotation is created, the definition may look like this :
The
ExtSpringBootTestContextBootstrapper
will have not issues functioning correctly with lack of@SpringBootTest
since the only method that reads it isorg.springframework.boot.test.context.SpringBootTestContextBootstrapper#getAnnotation(java.lang.Class<?>)
and this method can be overridden by
ExtSpringBootTestContextBootstrapper
to search for@ExtSpringBootTest
.However, this is not the case with
SpringBootContextLoader
. The@SpringBootTest
annotation is reference in a few places, mostly in order to get the.isEmbedded
property. This require anyExtSpringBootContextLoader
to override more then one method, and copy paste some code...Also,
@SpringBootTest
is reference inTestRestTemplateContextCustomizer
andWebTestClientContextCustomizer
.Its a shame that is is now almost possible to easily extend the bootstrap... the few small changes suggested here could complete this ability.
The text was updated successfully, but these errors were encountered: