Recipe Dummy Launcher
Nico Küchler edited this page Apr 25, 2016
·
6 revisions
Avoid that your app is closed when you back press on your root activity.
Create an activity with an button to start your start activity. In your Espresso Tests use this activity as start activity. Now when you press back button on your typically start activity this dummy launcher activity is shown instead of closing your application.
Since Espresso Macchiato 0.4
Instead of creating your own dummy launcher you can use the prepared activity.
Warning: Work only for library modules. For application modules the activities manifest entry can not be done in androidTest scope. Instead use the debug or some testing type scope.
public class MyTest extends EspressoTestCase<EspDummyLauncherActivity> {
@Befor
public void setup() {
EspDummyLauncherActivity activity = getActivity();
activity.setStartIntent(BaseActivity.class);
activity.start();
}
}