Android: synchronizer testing

I have a sync adapter that syncs contacts with a private server. It looks something like the SampleSyncAdapter in samples (but, of course, modified to suit my needs).

I need to write tests for this sync adapter. Can someone give me some guidelines on how to write these tests?

I am stuck in checking contact operations (create, update, delete). How can I mock a contact database so that I can test it instead of a real contact database?

thanks

+6
source share
1 answer

I could not find a solution for this, so I decided to create a new account in setUp() , run the tests and delete the account at the end. Thus, I can test operations with a real database, but in a different account. Therefore, I can run my tests, but without changing existing contacts.

+2
source

Source: https://habr.com/ru/post/957896/


All Articles