Changing the Order of Tests in JUnit5

Multiple tests within a suite are expected to be independent in most cases. If changing the order that the tests are run subsequently causes a different outcome, such as a failed test or different failed tests, it is possible, or even likely, a sign of an underlying bug in the test class or application under test.

A test could cause an inconsistency in the database that is only detected when tests are executed in a different order. Another possibility is that a test positioned at the end could inadvertently take into account a change in the data from an earlier test and fail when it is run in isolation or at the beginning of the suite.