How to relaunch the closed app in Robotium?

自作多情 提交于 2019-12-01 07:28:30

问题


I started to automate my Android app. It has a "Terms & conditions" screen. In that, if I click on "decline", my app will be closed.

How can I relaunch or restart my app within the same process?


回答1:


Try this:

// assuming this method is in a ActivityInstrumentationTestCase2 class
public void test_yourTest() {

    // do your testing

    Solo.sleep(1000);

    // killing all your Activities manually if it doesn't by itself anyway
    Solo.finishOpenedActivities();

    // relaunch your app by calling the same Activity as in the constructor
    // of your ActivityInstrumentationTestCase2
    this.launchActivity(TARGET_PACKAGE_ID, YourStartActivity.class, null);

    Solo.sleep(1000);

    // do your testing
}


来源:https://stackoverflow.com/questions/11644288/how-to-relaunch-the-closed-app-in-robotium

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!