mbmc
mbmc

Reputation: 5105

espresso to wait for activity onDestroy

The test is: in ActivityA, a button click starts ActivityB and closes ActivityA. How to test that ActivityA has been destroyed? I've created an IdlingResource to check isFinishing() or isDestroyed(), and also monitored a boolean in a custom ActivityTestRule, but it never gets called and times out.

I also tried to check when ActivityB gets created using intended/hasComponent but if I call right after perform(click()), it returns false.

All the animations / transitions are off.

Upvotes: 0

Views: 817

Answers (1)

CodyEngel
CodyEngel

Reputation: 1501

I wouldn't use Espresso to verify that onDestroy is being called. You should be doing higher level tests with Espresso such as testing that clicking a button will launch another activity, or when you enter in bad data and press submit an error shows up and is visible on the screen.

For testing onDestroy I would recommend doing that in a unit test and you can use something like Robolectric for that.

Upvotes: 1

Related Questions