Android activity is not finished despite finish been called when run in test

Viewed 226

If the result in onActivityResult is correct I finish the activity:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == REQUEST_TAKE_PHOTO) {
     // do some magic
     setResult(Activity.RESULT_OK);
     finish();
   }
}

The above works perfectly fine when run in normal flow, but when I run it in test with Espresso it doesn't finish activity.

The app is finished somewhere after onResume is called.

Question: why? Or did I accidentally depend on unspecified behaviour?

I've added a variable to keep the state of result as workaround.

0 Answers
Related