mardi 16 juin 2015

How to unit test Content provider and DB calls in robolectric which has native dependencies

I want to use robolectric(3+) for unit testing in my project. The issue is that in our project we are not using the sqlite dependencies from android.database.sqlite but the compiled source code from sqlite project(org.sqlite.database). This is because we are using hardware based encryption in our DB for security. The dependencies on org.sqlite.database calls native code. Robolectric does not support any external native code(will give java.lang.UnsatisfiedLinkError). The ContentProvider and SQLite helper class in my project references the code in org.sqlite.database packages for creating tables, building queries, table joins. Now, I can create another content provider for test cases, but it can cause code duplication and it won't be testing the actual content provider. Within the content provider, I can separate DB operations into different classes but again it will be code duplication. It seems like I have to run them as instrumented test cases. If anybody has some suggestions, it will be great.

Aucun commentaire:

Enregistrer un commentaire