-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: testIssues in the test moduleIssues in the test moduletype: enhancementA general enhancementA general enhancement
Milestone
Description
Overview
The Javadoc of @BootstrapWith currently states:
This annotation may also be used as a meta-annotation to create custom composed annotations. Note, however, that a locally declared
@BootstrapWithannotation (i.e., one that is directly present on the current test class) will override any meta-present declarations of@BootstrapWith.
However, if one tries to declare an annotation at the class level that overrides a declaration that is meta-annotated, this leads to:
Suppressed: java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class [com.example.demo.DemoCustomTestBootstrapApplicationTests]: [@org.springframework.test.context.BootstrapWith(value=com.example.demo.CustomTestContextBootstrapper.class), @org.springframework.test.context.BootstrapWith(value=org.springframework.boot.test.context.SpringBootTestContextBootstrapper.class)]
at org.springframework.test.context.BootstrapUtils.resolveExplicitTestContextBootstrapper(BootstrapUtils.java:193)
at org.springframework.test.context.BootstrapUtils.resolveTestContextBootstrapper(BootstrapUtils.java:150)
at org.springframework.test.context.BootstrapUtils.resolveTestContextBootstrapper(BootstrapUtils.java:126)
at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:126)
at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1916)
at org.springframework.test.context.junit.jupiter.SpringExtension.getTestContextManager(SpringExtension.java:427)
at org.springframework.test.context.junit.jupiter.SpringExtension.afterAll(SpringExtension.java:181)
With the following declaration:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootTest
@BootstrapWith(CustomTestContextBootstrapper.class)
public @interface CustomTest {
}I am not sure if the Javadoc is wrong or if the use case above is meant to be supported. Knowing that will help figure out our options for spring-projects/spring-boot#15077.
Related Issues
- Explicit failure if multiple @BootstrapWith annotations are used on the same test [SPR-12602] #17203
- Relax explicit TestContextBootstrapper resolution [SPR-17006] #21544
- Provide module-scoped equivalents to @WebMvcTest and @DataJpaTest moduliths/moduliths#5
- Allow proper replacement of @SpringBootTest and extension of SpringBootTestContextBootstrapper spring-boot#15077
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test moduletype: enhancementA general enhancementA general enhancement