Skip to content

Instantly share code, notes, and snippets.

View brettwold's full-sized avatar

Brett Cherrington brettwold

View GitHub Profile
@brettwold
brettwold / BaseTestClass.java
Last active February 10, 2016 18:17
How to make RxJava threading run instantly in JUnit/Robolectric tests
public class BaseTestClass {
@Before
public void setup() {
ShadowLog.stream = System.out;
RxJavaTestPlugins.resetPlugins();
RxJavaTestPlugins.getInstance().registerSchedulersHook(new RxJavaSchedulersHook() {
@Override
@brettwold
brettwold / AlertTest.java
Last active September 16, 2015 14:29
Robolectric test for AlertDialog display
public class AlertTest {
@Test
public void check_alert() {
AlertDialog alert = ShadowAlertDialog.getLatestAlertDialog();
assertNotNull(alert);
ShadowAlertDialog sAlert = Robolectric.shadowOf(alert);
assertThat(sAlert.getTitle().toString(), is(Robolectric.application.getString(R.string.adb_warning_title)));
}
}