简体   繁体   中英

Robotium Android How to stop the app being killed after test completes.?

Normally when we run the test app is killed after test completes. But in my case i am running couple of background services (cloud sync ) so i dont want to kill the app until service finishes its tasks.

What i tried is

In teardown i removed the methods

solo.finishOpenedActivities(); and super.tearDown();

 public void tearDown() throws Exception {
    //solo.finishOpenedActivities();
    //super.tearDown();
}

but it still kills the app.

Solutions needed.

1-> Dont kill the app after test completes.

Or

2 -> Kill the app after background service finishes its task.

Thank you in advance.

If you want one test to live as long as your background service still lives, maybe with a timeout to get sure the test always finishes, then you should :

  • bind to your service inside the test
  • listen to the service completion, this means you have to be able to notfied of the service's lifecycle via the binder
  • unbind from it when you receive an event from the service
  • you can use CountDownLatch to get sure the service finishes properly in your test.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM