Test order with espresso

前端 未结 7 871
天涯浪人
天涯浪人 2021-01-01 10:20

Is there a way to set test running order in android?
I use Espresso framework and need to test a lot of activities and transitions between them. I want to write differen

7条回答
  •  心在旅途
    2021-01-01 11:03

    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");
       }
    }
    

提交回复
热议问题