Description
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 :
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@BootstrapWith(ExtSpringBootTestContextBootstrapper.class)
public @interface ExtSpringBootTest {}
The ExtSpringBootTestContextBootstrapper
will have not issues functioning correctly with lack of @SpringBootTest
since the only method that reads it is org.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 any ExtSpringBootContextLoader
to override more then one method, and copy paste some code...
Also, @SpringBootTest
is reference in TestRestTemplateContextCustomizer
and WebTestClientContextCustomizer
.
Its a shame that is is now almost possible to easily extend the bootstrap... the few small changes suggested here could complete this ability.