How To Test If A Fragment Is Visible With Espresso
I wrote a very simple Activity with a Button. When the button is clicked, I will start a new Fragment. Now I want to test this logic in my Espresso UI Test. So I wrote this UI Test
Solution 1:
Try the following:
@Test
fun switchToFragment() {
onView(withId(R.id.btn)).perform(click())
onView(withId(R.id.fragment)).check(matches(isDisplayed()))
}
If you're just learning about Espresso, the official guide is a good place to start. Also, here's the Espresso cheat sheet.
Post a Comment for "How To Test If A Fragment Is Visible With Espresso"