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 for my Activity
@RunWith(AndroidJUnit4::class)
@LargeTest
class MainMenuUiTest {
@get: Rule
val activityTestRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java)
@Test
fun switchToFragment() {
onView(withId(R.id.btn)).perform()
}
}
How can I test that my Fragment
is displayed when the button is clicked?