Android testing. Espresso. Change text in a TextView

前端 未结 4 1583
南方客
南方客 2020-12-10 16:01

It is easy to update an EditText with Espresso, but I can not find a way to change a text (like with a TextView.setText(\"someText\"); method) during the testing process.

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-10 16:10

    You can simply add your layout TextView in your layout that you have declared

    
    
        
    
    

    ** Write code in test class to check text is displaying on textview**

     @Test
    public void checkUserId(){
        Espresso.onView(withId(R.id.textView)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    }
    

提交回复
热议问题