Skip to content

Instantly share code, notes, and snippets.

@jaredsburrows
Created November 19, 2016 01:33
Show Gist options
  • Save jaredsburrows/f0115dcd19307d91f2a7eb459437a5bf to your computer and use it in GitHub Desktop.
Save jaredsburrows/f0115dcd19307d91f2a7eb459437a5bf to your computer and use it in GitHub Desktop.
import org.junit.After;
import org.junit.Before;
import rx.Scheduler;
import rx.android.plugins.RxAndroidPlugins;
import rx.android.plugins.RxAndroidSchedulersHook;
import rx.schedulers.Schedulers;
/**
* JUnit Tests.
*
* @author <a href="mailto:[email protected]">Jared Burrows</a>
*/
public abstract class RxTestBase extends TestBase {
@Before public void setUp() throws Exception {
super.setUp();
// Android
RxAndroidPlugins.getInstance().reset();
RxAndroidPlugins.getInstance().registerSchedulersHook(new RxAndroidSchedulersHook() {
@Override public Scheduler getMainThreadScheduler() {
return Schedulers.immediate();
}
});
}
@After public void tearDown() throws Exception {
super.tearDown();
// Android
RxAndroidPlugins.getInstance().reset();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment