I have noticed that every now and then there is a question about using Robolectric for testing custom ContentProviders. However, there has never been a concrete and unambiguous answer on how to do it properly. I have stumbled upon 2 different approaches:

However, I'm getting a java.lang.InstantiationException with both approaches. There have been some SO posts saying that this is due to SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java) not being overriden in Robolectric (Android + Robolectric - RuntimeException / InstantiationException in queryBuilder.query() in ContentProvider).

I guess my question is - are there any preffered workarounds that make testing ContentProviders possible. Or are there any other approaches that are better then those 2 mentioned above.

Edit
Report