Test order with espresso

As @spinster said above, you should write your tests in a way where order doesn't matter.

I believe Junit 3 will run tests in alphabetical order of the fully qualified class name, so in theory you could control the order by naming them ( package name, class name, method name ) alphabetically in the order you would like them executed, but I would not recommend that.

See: How to run test methods in specific order in JUnit4? How to pre-define the running sequences of junit test cases?


espresso set running order of tests

From Junit 4.11 comes with @FixMethodOrder annotation. Instead of using custom solutions just upgrade your junit version and annotate test class with FixMethodOrder(MethodSorters.NAME_ASCENDING). Check the release notes for the details.

Here is a sample:

import org.junit.runners.MethodSorters;

import org.junit.FixMethodOrder;
import org.junit.Test;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SampleTest {

   @Test
   public void A_firstTest() {
      System.out.println("first");
   }

   @Test
   public void B_secondTest() {
      System.out.println("second");
   }
}