Skip to content

Property value from context is unexpected when run junit tests in parallel (context corrupted?) #34339

Open
@verusikk

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 @TestPropertySource for each test
  • use different value for @ActiveProfiles for each test

How to reproduce
Clone https://github.com/verusikk/spring-boot-integration-tests-issue, use README.md commands to run integration tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    in: testIssues in the test modulestatus: waiting-for-triageAn issue we've not yet triaged or decided on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions