TestMethodOrder not respected under concurrent execution
0 reputation · 12 Oct 2023, 22:56 UTC
TestMethodOrder not respected under concurrent execution
When enabling parallel test execution in JUnit 5 with @Execution(ExecutionMode.CONCURRENT), the ordering specified by @TestMethodOrder appears to be ignored, causing interleaved test runs that break assumptions about state initialization.
The goal is to understand whether the ordering guarantee holds when tests are scheduled on multiple threads, and if not, what mechanisms can be applied to preserve a deterministic order without sacrificing parallelism.
Constraints include the default dynamic scheduling strategy, the presence of shared static state, and the requirement to keep the test suite’s total runtime low.
- Is
@TestMethodOrderguaranteed to be respected when@Execution(ExecutionMode.CONCURRENT)is active? - What configuration options or annotations can enforce a specific execution order across threads?
- Are there documented limits or recommended patterns for combining
@TestMethodOrderwith parallel execution?