rx-kotlin

RxJava 2 overriding IO scheduler in unit test

拜拜、爱过 提交于 2019-12-03 07:06:28
问题 I'm trying to test the following RxKotlin/RxJava 2 code: validate(data) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .flatMap { ... } I'm attempting to override the schedulers as follows: // Runs before each test suite RxJavaPlugins.setInitIoSchedulerHandler { Schedulers.trampoline() } RxAndroidPlugins.setInitMainThreadSchedulerHandler { Schedulers.trampoline() } However, I get the following error when running the test: java.lang.ExceptionInInitializerError ...