Testing RxAndroid Plugin Scheduler Management in ReactiveX/RxAndroid
This test suite validates the RxAndroidPlugins functionality without Robolectric dependency, specifically focusing on scheduler manipulation and plugin reset capabilities. The tests ensure proper handling of main thread scheduler replacement in RxAndroid.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
reactivex/rxandroid
rxandroid/src/test/java/io/reactivex/rxjava3/android/plugins/RxAndroidPluginsNoRobolectricTest.java
package io.reactivex.rxjava3.android.plugins;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.android.testutil.EmptyScheduler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertSame;
public final class RxAndroidPluginsNoRobolectricTest {
@Before @After
public void setUpAndTearDown() {
RxAndroidPlugins.reset();
}
@Test public void mainThreadSchedulerCanBeReplaced() {
EmptyScheduler emptyScheduler = new EmptyScheduler();
RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> emptyScheduler);
assertSame(emptyScheduler, AndroidSchedulers.mainThread());
}
}