ReactiveX / RxAndroid

RxJava bindings for Android
Apache License 2.0
19.89k stars 2.95k forks source link

Integration with Robolectric @LooperMode #554

Closed snepalnetflix closed 4 years ago

snepalnetflix commented 4 years ago

Robolectric recently introduced support for background threads, see: http://robolectric.org/blog/2019/06/04/paused-looper/

I tried using the new @LooperMode(PAUSED) annotation on my existing test but RxJava IO schedulers still seem to run their work on the main thread.

Is there any trick to integrating with the new looper mode?

JakeWharton commented 4 years ago

The IO scheduler comes from RxJava, not RxAndroid, and thus does not use Loopers on threads. You'll have to use mechanisms like the RxJavaPlugins to replace the scheduler in tests with something that you can control.