Android Espresso : correctly test closing app with pressBack
问题 I'm trying to implement some navigation tests with espresso. Actually i want to check if the application has been closed by the use of the Back key on the main screen, just after a fresh start. Here is a piece of code i'm using. class NavigationTests { @get:Rule val mActivityTestRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java) @Test fun backOnEmptyHomeMustExit(){ Espresso.pressBack() Assert.assertTrue(mActivityTestRule.activity==null) } } Actually i got a test