I have a sync adapter that is synchronizing the contacts with a private server. It looks something like the SampleSyncAdapter in the samples (but of course modified to meet my needs).
I need to write tests for this sync adapter. Can anyone give me some guides on how to write these tests?
I got stuck with testing the contacts operations (create, update, delete). How can I mock the contacts database so I can that one for testing instead of the the real contacts database?
Thank you
The sync adapter component in your app encapsulates the code for the tasks that transfer data between the device and a server. Based on the scheduling and triggers you provide in your app, the sync adapter framework runs the code in the sync adapter component.
Offline sync allows end users to interact with a mobile app—viewing, adding, or modifying data—even when there's no network connection. Changes are stored in a local database. Once the device is back online, these changes are synced with the remote backend.
The main() method is in the Android framework class android. app. ActivityThread . This method creates the Main (UI) Thread , sets up a Looper on it and starts the event loop.
I couldn't find solution for this, so I decided to create new account in setUp()
, run the tests and delete the account at the end. This way I can test the operations with the real database but in different account. So I can run my tests, but without changing the existing contacts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With