vendredi 2 octobre 2015

How to mock permissions for testing in Android?

With Android 6.0 and new permission model, I am checking if the permission exists before performing certain task.

I want to assign these permissions to available and not available for testing purpose. I have a static class to check various permissions depending on the string.

boolean result = ContextCompat.checkSelfPermission(context, name) == PackageManager.PERMISSION_GRANTED;

Can it be achieved using Mockito or Roboelectric?

Aucun commentaire:

Enregistrer un commentaire