JUnit 5 Test Method Ordering: Default Execution Sequence Undefined
0 reputation · 12 Dec 2021, 17:09 UTC
Background
JUnit 5 allows explicit ordering of test methods via @TestMethodOrder. When this annotation is omitted, the framework does not guarantee any particular execution order. The current documentation states that the default is implementation‑dependent, which can vary across JVMs, build tools, or JUnit releases.
Unresolved Decision
The lack of a documented default order is a design choice that remains open. Test suites that inadvertently rely on implicit ordering may exhibit flaky behavior, especially when parallel execution is enabled or when running under different environments.
Key Questions
- What is the actual default execution order of test methods in JUnit 5 when
@TestMethodOrderis not applied? - Does the default order depend on the JVM implementation, build tool, or specific JUnit 5 version?
- What are the practical implications for test reliability and reproducibility when implicit ordering is relied upon?