KentBeck/junit — pull request #386 by matthewfarwell (2012-02-19 10:44:53+00:00)
Title: SortMethodsWith allows the user to choose the order of execution of the methods within a test class

The default order of execution of JUnit tests within a class
is deterministic but not predictable. Before 4.11, the
behaviour was to run the test methods in byte code order,
which pre-Java 7 was mostly predictable. Java 7 (and some
previous versions), does not guaranteee the order of execution,
which can change from run to run, so a deterministic sort was introduced.
As a rule, test method execution should be independent of
one another. However, there may be a number of dependent
tests either through error or by design. This class
allows the user to specify the order of execution of test methods.

There are four possibilities:

MethodSorters.DEFAULT: the default value, deterministic, but not predictable
MethodSorters.JVM: the order in which the tests are returned by the JVM, i.e. there is no sorting done
MethodSorters.NAME_ASC: sorted in order of method name, ascending
MethodSorters.NAME_DESC: sorter in order of method name, descending

This is an enhancement to the solution for #293 Sort test methods for predictability, in order that users can temporarily 'fix' their broken tests, from https://github.com/KentBeck/junit/pull/293#issuecomment-2095777