-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IdlingRegistry doesn't set registerIdleTransitionCallback until a IdlingResourceRegistry sync #20
Comments
Related to this, we get a similar crash by trying to do the init "(RxJavaPlugins.setInitIoSchedulerHandler(Rx2Idler.create(RXJAVA_IO_SCHEDULER_NAME))" in TestRunner's onCreate (otherwise, the app init creates schedulers before onStart so it will never get overridden w/ the idling one). If we do the init in onStart, the IOScheduler is already started so InitIoSchedulerHandler never gets called (verified w/ breakpoints) |
DelegatingIdlingResourceScheduler.stopWork() probably needs a null check for callback but it also looks like it's not initialized properly... |
I'm having a crash in |
I've written a workaround for this error while the issue is not merged, it's far from perfect but it does the trick for me.
I'm not sure if a simple call to Espresso.onIdle would suffice, and since I can't seem to reproduce it consistently I went with a flow that I could easily track. If there's a cleaner way to do this please let me know |
io.reactivex.rxjava2:rxandroid:2.1.0
io.reactivex.rxjava2:rxjava:2.2.2
com.squareup.rx.idler:rx2-idler:0.9.1
androidx.test.espresso:espresso-core:3.2.0
androidx.test.espresso:espresso-idling-resource:3.2.0
I have an application that injects our ScheduleProviders, so in our test app component I was having to use the
RxIdler.wrap()
functionality and I am registering them as IdlingResources in a custom ActivityTestRule before thebase?.evaluate()
.Since
Espresso.registerIdlingResources()
is now a deprecated function, I was using theIdlingRegistry.getInstance().register()
. However I have a couple of tests that have no UI interactions that were crashing for null pointer exceptions on theDelegatingIdlingResourceSchedulers.stopWork()
for a null ResourceCallback. Even though I could debug through and see the Schedulers in the list of registered resources in the IdlingRegistry. This didn't happen if I changed the call to use the deprecatedEspresso.registerIdlingResources()
.After much debugging I discovered that this is because:
Espresso.registerIdlingResources()
immediately causes a sync on the IdlingResourceRegistry which is where the registerIdleTransitionCallback() happens. Whereas the IdlingRegistry does not sync with the IdlingResourceRegistry until an IdleNotifier is necessary.I am able to force this by calling an Espresso interaction immediately after registering.
All of my tests now work the same by exchanging
with
I thought this information might help a few other people, or could be an addition to the README for how to fully register these IdlingResources with the newer IdlingRegistry.
The text was updated successfully, but these errors were encountered: