spring-projects / spring-projects/spring-framework
Introduce support for test-scoped beans in the TestContext framework [SPR-14034]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Caleb Cushing opened SPR-14034 and commented
I'd like to be able to register a bean as @Scope("test") (or @TestScope), so that after an integration test is executed this bean is cleaned up. I don't want to use @DirtiesContext because this is the only bean I want to throw away.
For the actual use case I've built a sort of "Login Manager" for selenium that knows which user is currently logged in and which roles have test users created for them. This can't be shared between tests because we only allow a single session for a user.
I looked to see if this exists in the reference documentation and couldn't find anything.
Related Issues
- #13352 Publish TestStarted and TestCompleted events in the TestContext framework
- #18490 Publish TestExecutionListener events to the ApplicationContext under test
No further details from SPR-14034
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
No source file or test is identified in the issue. Start by reviewing the TestContext framework and the related issues #13352 and #18490, then determine the required test-scope lifecycle and cleanup behavior; done means the requested scoped-bean support works without discarding the whole application context.
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
- Needs clarification
- Newbie friendliness
- 30/100