muetzenflo muetzenflo - 3 years ago 110
Android Question

Robolectric + Mockito + Marshmallow + Permissions

I am trying to write a unit test for a method that depends on the result of

. To do so, I need to do two things:

  1. call

    which depends on an Activity built by

  2. call

    which depends on an Activity built by


So when I create my Activity with Robolectric, I cannot use the Mockito.verify.
And when I create my Activity with Mockito, I cannot use the Robolectric.grantPermission.

How can I cover this? I'm new with both frameworks, so maybe I am missing something simple.

Answer Source

Haven't checked it out in detail, but since today it should be possible to make use of GrantPermissionRule by using the new Android Testing Support Library

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download