You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just started experimenting with RxJava/RxAndroid 2.0.0-RC2 on an Android app and when attempting to write a (JVM) unit test which replaces AndroidSchedulers.mainThread() with a Scheduler defined via RxAndroidPlugins it seems that this is not possible as it requires Android Handler and Looper dependencies.
This is the Exception that is reported when I attempt to execute the unit tests:
java.lang.ExceptionInInitializerError
at <blah, blah>
Caused by: java.lang.RuntimeException: Method getMainLooper in android.os.Looper not mocked. See http://g.co/androidstudio/not-mocked for details.
at android.os.Looper.getMainLooper(Looper.java)
at io.reactivex.android.schedulers.AndroidSchedulers.<clinit>(AndroidSchedulers.java:24)
... 32 more
And this is the code in question from AndroidSchedulers in RxAndroid 2.0.0-RC2:
// snipprivatestaticfinalSchedulerMAIN_THREAD = RxAndroidPlugins.initMainThreadScheduler(
newHandlerScheduler(newHandler(Looper.getMainLooper())));
/** A {@link Scheduler} which executes actions on the Android main thread. */publicstaticSchedulermainThread() {
returnRxAndroidPlugins.onMainThreadScheduler(MAIN_THREAD);
}
//snip
Looking at the previous AndroidSchedulers definition from Rx 1.x, this was not the case as it would return the plugin's instance without attempting to evaluate the statement with Android dependencies on demand: the RxAndroidPlugins instance would take preference.
So a few questions. Is my evaluation correct or am I missing something? Secondly, is this the intended behavior?
The text was updated successfully, but these errors were encountered:
peter-tackage
changed the title
AndroidSchedulers.mainThread() has Android dependencies
AndroidSchedulers.mainThread() has Android dependencies in RxAndroid 2.0.0-RC2
Sep 20, 2016
I've just started experimenting with RxJava/RxAndroid 2.0.0-RC2 on an Android app and when attempting to write a (JVM) unit test which replaces
AndroidSchedulers.mainThread()
with aScheduler
defined viaRxAndroidPlugins
it seems that this is not possible as it requires AndroidHandler
andLooper
dependencies.This is the Exception that is reported when I attempt to execute the unit tests:
And this is the code in question from
AndroidSchedulers
in RxAndroid 2.0.0-RC2:Looking at the previous
AndroidSchedulers
definition from Rx 1.x, this was not the case as it would return the plugin's instance without attempting to evaluate the statement with Android dependencies on demand: theRxAndroidPlugins
instance would take preference.So a few questions. Is my evaluation correct or am I missing something? Secondly, is this the intended behavior?
The text was updated successfully, but these errors were encountered: