Espresso 2 on Android, intermediately tests fail after failing to start the activity under test while activities from previous tests are still alive

前端 未结 1 2049
我寻月下人不归
我寻月下人不归 2021-02-09 03:09

I am using Espresso 2 for testing my Android app. Intermediately I see tests randomly fail with this Espresso failure message:

failed: testLongPressXXXXX (com.compan

1条回答
  •  难免孤独
    2021-02-09 03:42

    This question was asked a while ago but since this still seems to be relevant I thought I'd share what I found. I am facing a similar problem - AmbiguousViewMatcherException on Views that have a unique id, different tests failing randomly - probably due to Activities not being destroyed.

    This seems to be a known issue and should be addressed in the next release (see here: https://github.com/google/android-testing-support-library/issues/16). Apparently onDestroy() and isFinishing() are not called reliably after each test so you might not get a fresh Activity every time or even end up with two Activities on top of each other.

    Until they fix it I've decided not to waste my time on a workaround but starting using Genymotion emulators which solved my problem - possibly because they run faster than the built-in ones in Android Studio (as was suggested here).

    0 讨论(0)
提交回复
热议问题