Test order with espresso

前端 未结 7 853
天涯浪人
天涯浪人 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:02

    You have 3 ways:



    way 1: JUnit 4 and 5 work

    @Test
    public void testFunctionMain() {
        test1(); 
        test2()
        test3(); 
    }
    

    way 2: JUnit 4 and 5 work

    use @FixMethodOrder

    @FixMethodOrder(MethodSorters.NAME_ASCENDING)
    @RunWith(AndroidJUnit4::class)
    class LoginActivityTest {
    }
    

    way 3: Junit5 work

    use @Order

    @Test
    @Order(2)
    public void testFunction(){
    }
    

提交回复
热议问题