I'm trying to test a ContentProvider class, and can't make it work.
getProvider() keeps returning null, but as I understand from the ProviderTestCase2.setUp() code, it shouldn't.
public class NotesProviderTest extends ProviderTestCase2<NotesProvider>
{
...
public NotesProviderTest()
{
super(NotesProvider.class, Contract.AUTHORITY);
}
@Override
protected void setUp() throws Exception
{
super.setUp();
}
public void testNoteProvider__inserts_a_valid_record() throws Exception
{
Note note = new Note(new JSONObject(simpleNoteJson));
NotesProvider provider = getProvider();
Uri insert = provider.insert(Note.URI, note.getContentValues());
assertEquals(1L, ContentUris.parseId(insert));
Cursor cursor = provider.query(Note.URI, null, null, new String[]{}, null);
assertNotNull(cursor);
cursor.close();
}
}
Side note: the provider works if used within the app.
Thanks in advance.