How to test a Toast in a fragment
How do you create a Test that confirms a Toast is displayed in a fragment.
Here are the bones of my test
@RunWith(AndroidJUnit4:class)
class MyFragmentTest() {
val displayToast = R.id.btn_toast
@Before()
fun setup() {
launchFragmentInContainer(null, R.style.My_Theme)
}
@Test
fun displayToast() {
onView(withId(displayToast).perform(click())
// Insert different ideas here to display toast.
}
}
Idea one
onView(WithText("My...