spring-projects / spring-projects/spring-framework
Allow `TestContextBootstrapper` to be configured globally without `@BootstrapWith`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
I find myself needing to customize the ContextCache so that I can run tests in parallel JUnit. Yes can be done with @BootstrapWith, but it is quite burdensome to have to add this so every single test class. This is fine for a handful of classes, but not feasible with over 100 test classes.
I have worked out how to create separate Postgres databases for each application context that loads with an ApplicationContextInitializer, which can be done globally with spring.factories, but as far as I can tell, the TestContextBootstrapper can only be overridden at the class level.
I cannot use @DirtiesContext because again, I would have to annotate every class, and this is causing my Hikari pool to get closed.
In summary, it would be much appropriated to be able to customize ContextCache globally for all tests.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading TestContextBootstrapper and the existing @BootstrapWith configuration path to understand how bootstrapper selection is currently scoped. Define how a global configuration would be discovered and applied, then add coverage showing that the selected bootstrapper affects all applicable test classes without per-class annotations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100