spring-projects / spring-projects/spring-framework
Property value from context is unexpected when run junit tests in parallel (context corrupted?)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Description
Integration tests in a Spring Boot application run in parallel and set a variable using @DynamicPropertySource. Each test is expected to start its own Spring context with separate beans and properties, but properties value is unexpectedly overwritten by other tests.
Reproducer
A small reproducer for the issue has been prepared: GitHub Repository (Java 21, Kotlin, Gradle).
During execution, each test launches a Spring Batch job, passing the assigned parameter value. The job then verifies that this value matches the one in its context. When tests run in parallel, some of them fail because the expected and actual values do not match.
However, when running tests sequentially (without parallelization), all tests pass successfully.
What was tried
- set property with
@TestPropertySourcefor each test - use different value for
@ActiveProfilesfor each test
How to reproduce
Clone https://github.com/verusikk/spring-boot-integration-tests-issue, use README.md commands to run integration 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
Clone the linked reproducer and follow its README.md commands to run the integration tests. Compare parallel execution with sequential execution and inspect how @DynamicPropertySource and Spring test contexts are used. Done means identifying the context or property isolation issue and confirming that the parallel tests consistently retain their assigned values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin, spring
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100