How to control test class execution order in JUnit 5 suites? #5085
Unanswered
abhiramreddy1818
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
That's currently not possible since If you're looking for a lifecycle hook to run some code before the first test in the suite (or after the last), have you considered using |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How to control test class execution order in JUnit 5 suites?**
I'm organizing my tests using JUnit 5's
@Suiteand@SelectClassesbut need to control the execution sequence of the test classes. According to the documentation,@SelectClassesdoesn't guarantee execution order, but I have a specific sequence requirement for my test pipeline.Here's my current suite setup:
The subordinate suites look like:
My test dependencies require that:
Test1executes first (initial setup and validation)Suite1,Suite2,Suite3execute in between (main test batches)Test2executes last (cleanup and final verification)What I've tried/researched:
@TestMethodOrderfor ordering methods within a class, but I need class-level ordering across the suite@Suitedocumentation but didn't find explicit ordering controlsQuestion:
What is the standard JUnit 5 approach to enforce test class execution order within a suite? If declarative ordering isn't supported, what are the recommended patterns or workarounds to achieve this test sequence?
I'm using JUnit 5.8+/Jupiter with the junit-platform-suite engine.
Beta Was this translation helpful? Give feedback.
All reactions