android-test icon indicating copy to clipboard operation
android-test copied to clipboard

Espresso:- IdlingResources must support Databinding

Open jongerrish opened this issue 6 years ago • 3 comments

DataBinding uses different approach to schedule an update, it uses Choreographer.postFrameCallback. So updates are not posted into looper queue and Espresso will not wait for them.

See: https://stackoverflow.com/questions/40703567/how-do-i-make-espresso-wait-until-data-binding-has-updated-the-view-with-the-dat

jongerrish avatar Apr 29 '19 14:04 jongerrish

Perhaps this should be reworded as 'DataBinding' requires a custom IdlingResource? Since there is a IR sample for DataBinding that seems to work.

Both @slinzner and I looked into this and didn't think it was feasible for Espresso to use Choreographer as an idling resource

brettchabot avatar May 15 '19 21:05 brettchabot

My espresso tests were working fine before I updated to AS 3.6 with

viewBinding {
        enabled = true
    }

Now, when I do something like this it is not working:

public static void tapCard(String PageName) throws Throwable {
       Lets.performAndTakeSS(On.LocationsListDetails.CARDS_RECYCLER_VIEW, RecyclerViewActions.scrollTo(hasDescendant(EspressoMatchers.withText(EspressoMatchers.endsWith(PageName)))));
       Lets.performAndTakeSS(On.LocationsListDetails.CARDS_RECYCLER_VIEW, RecyclerViewActions.actionOnItem(hasDescendant(EspressoMatchers.withText(EspressoMatchers.endsWith(PageName))), click()));
   }

Am I supposed to change anything to work with viewbinding? Seeing this issue especially with Fragments.

https://github.com/android/testing-samples/issues/314

thrlr123 avatar Apr 01 '20 19:04 thrlr123

Just to clarify, View binding doesn't have this problem right?

seadowg avatar Apr 05 '24 14:04 seadowg