-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests for DeveloperSettings should use mock of SharedPreferences #53
Comments
What do you think about to use a wrapper interface as a collaborator of |
+1 I also did that once |
Ok, I will do a PR with that ;) |
Okay :) |
@JcMinarro maybe even go one step ahead and provide a library for it then everyone could use that wrapper for sharedpreferences I was multiple times in that point where I was close to creating one already |
@vanniktech It could be a good option. I am going to implement it on qualitymatters project and later I try to extract it on a library ;) |
We can also use Mock SharedPreferences with Mockito. It is good for unit test too. |
What I was doing for unit tests was just a simple implementation using a HashMap. Adventage of that was that the end of the test you could verify whether the entries where in the shared preferences or not. |
@vanniktech +1 |
We could use a |
How about the idea of using this library. And then in DeveloperSetting class we have some standalone properties like:
In test method, we can easy to mock those things separately. But it will look annoying if we have to many things on DeveloperSetting class. |
@JcMinarro any progress on the sharedpreferences lib? |
Currently it's more integration tests rather than a unit. For example, we don't know if it really writes values to
SharedPreferences
and reads them back or if it stores values just in memory.The text was updated successfully, but these errors were encountered: