I know unit tests should be flexible enough to be run in different order. But I have situation where I would want my test cases to run in a specific order. In this scenario I am testing my controllers with fakeApplication and FakeRequest of playframework 2.3. Despite annotating my test class with FixMethodOrder as NAME_ASCENDING my tests run in random order.
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class JobTest {
@Test
public void _1_addJob() {
running(fakeApplication(), new Runnable() {
@Override
public void run() {
}
});
}
@Test
public void _2_editJob() {
running(fakeApplication(), new Runnable() {
@Override
public void run() {
}
});
}
}
See below the screenshots where the test orders are swapped with no change in code.