How to relaunch the closed app in Robotium?

后端 未结 1 1272
失恋的感觉
失恋的感觉 2021-01-15 04: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 c

相关标签:
1条回答
  • 2021-01-15 05:19

    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
    }
    
    0 讨论(0)
提交回复
热议问题