如何重新启动Robotium中关闭的应​​用程序?

问题描述:

我开始自动化我的Android应用程序。它有一个“条款&条件”屏幕。在这一点上,如果我点击“拒绝”,我的应用程序将被关闭。如何重新启动Robotium中关闭的应​​用程序?

如何在同一过程中重新启动或重新启动我的应用程序?

试试这个:

// 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 
} 
+0

感谢。如果你想,请前往http://stackoverflow.com/questions/30096491/lifecycle-testing-with-robotium-killing-and-restarting-activity/30099143#30099143并在那里发布你的答案。 – 2015-05-07 11:18:38