My application use Storage, but for testing I want to substitute it with mock object or smth like that. Is that possible in Android? If yes, could you please provide a link with example how to do it?
Thanks!
My application use Storage, but for testing I want to substitute it with mock
Share
You can use a mocking framework to do this. Check out this question and the answers for a list of mocking frameworks that work nicely with Android. I personally recommend Mockito, which recently got supported by Android.
Now the question is what to mock. You could try to mock the data storage mechanisms directly, but I would recommend wrapping the data storage in another layer of abstraction. This will give you a clean seam to inject a mock when testing. This design also gives you more flexibility in general (for example, you can change the specific kind of data storage without effecting the business logic of your app).
Let me know if this is the kind of information you are looking for.