How to test for the appearance of a Toast message

前端 未结 9 1448
一生所求
一生所求 2020-12-16 09:55

Would anyone know how to test for the appearance of a Toast message on an Activity?

I\'m using code similar to what the OP posted on this question for testing my pro

相关标签:
9条回答
  • 2020-12-16 10:20

    you can choose Robolectric test framework.For checking toast, you can use it as below:

    assertTrue(ShadowToast.showedCustomToast("message", R.id.message)); //R.id.message: textView ID
    
    0 讨论(0)
  • 2020-12-16 10:23

    I am using it like:

    wait_for_text("Notification message to be verified", timeout: 30)
    

    This is an alternate way which partially serves the purpose.

    0 讨论(0)
  • 2020-12-16 10:25

    Would anyone know how to test for the appearance of a Toast message on an Activity?

    You can't -- sorry. By which, I mean there is no way to ask Android "hey, is a Toast showing? and what does it look like?".

    0 讨论(0)
提交回复
热议问题