pilgr / Paper

Paper is a fast NoSQL-like storage for Java/Kotlin objects on Android with automatic schema migration support.
Apache License 2.0
2.34k stars 234 forks source link

Testing #129

Closed kar closed 6 years ago

kar commented 6 years ago

Hi! It seems like Paper can't be used in unit tests because of it's Android dependency. Any chance of making it possible to init Paper in "test mode"?

pilgr commented 6 years ago

I believe Paper shouldn't be involved in unit tests by any means. You should provide your custom class incapsulating Paper DB calls (e.g. DataProvider) and mock it in your tests. Same happens with any other Android API (Location API, SharedPreferences, SQLite etc) – you need an wrapper class around its API to be mocked.

As you test unit - you should test only your unit (class) without any third party dependency involved.