Property value from context is unexpected when run junit tests in parallel (context corrupted?) #34339
Labels
in: test
Issues in the test module
status: waiting-for-triage
An issue we've not yet triaged or decided on
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
@TestPropertySource
for each test@ActiveProfiles
for each testHow to reproduce
Clone https://github.com/verusikk/spring-boot-integration-tests-issue, use README.md commands to run integration tests.
The text was updated successfully, but these errors were encountered: