jeudi 10 septembre 2015

How to test a CursorLoader with AndroidJUnitRunner and JUnit4?

I am trying to use the new AndroidJUnitRunner and JUnit4 for android and all my espresso tests were easy to convert, but now my loader tests wont work. My loaders require a handler, which requires the UiThread, and the loader interface doesn't have any way to synchronously to ask for it.

@UiThreadTest
@Test
public void testContactLoader() {
    ContactLoader loader = new ContactLoader(InstrumentationRegistry.getTargetContext());
    Cursor = getLoaderResultSynchronously(loader); // I don't know how to implement this function
    // assert stuff
}

Has anyone done this? I saw a weird implementation here but I am not sure how that works.

Aucun commentaire:

Enregistrer un commentaire