run tests in what order?

How does IDEA decide what order to run tests in a package? (It's not alphabetical.)



I'm not sure about details, but conceptually the tests are run in random order. They are rerun with failed tests first however.


I realize that ideally JUnit tests are independent and that the framework doesn't provide a way to determine their order. They appear to be in random order. But I'm debugging a lack of independence in some tests, so I'd like to run them in a particular order.

Generally with tests I prefer deterministic behavior over randomness, because that makes it easier to reproduce and fix bugs.


The only way I've found to control the order of JUnit tests is to enforce the order using nested test suites.


That's an interesting idea, but I don't know how to run a test suite in IDEA's test runner either.


Please sign in to leave a comment.