0

Several years ago there was an option to check in test activity has been launched due test execution. Nowadays this class is deprecated. From docs it is not clear how to perform this scenario within ActivityScenario

It is possible to launch another activity within tests, but I do not see an option to check activity has been launched during test scenario. How do you solve this use case?

@Test
fun onStart_openMainScreen_checkThereIsAnListItem() {
    val activityScenario = ActivityScenario.launch(MainActivity::class.java)
    dataBindingIdlingResource.monitorActivity(activityScenario)

    onView(ViewMatchers.withId(R.id.nav_view))
        .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
    onView(withId(R.id.list))
        .perform(RecyclerViewActions.actionOnItemAtPosition<LawsAdapter.ViewHolder>(12, scrollTo()))
    onView(withId(R.id.list))
        .perform(RecyclerViewActions.actionOnItemAtPosition<LawsAdapter.ViewHolder>(12, click()))

    // TODO check details activity has been launched
    
    activityScenario.close()
}
Joe Dow
  • 1
  • 1
  • There's an androidx version of [espresso-intents](https://developer.android.com/training/testing/espresso/intents): `androidx.test.espresso:espresso-intents:3.4.0` The usage is the same as that original answer – Cruceo Nov 06 '21 at 20:27

0 Answers0