I am developing an Android app using Kotlin. I am writing instrumented tests for my application. I am granting the permissions in my test using GrantPermissionRule as below.
@get:Rule
var permissionRule: GrantPermissionRule = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION)
However, that does not fit well with my requirements. I am wiping out all the granted permissions after each does. Also, I like to test the scenarios where the permissions are not granted. I am launching the activity explicitly in my test like this.
@Test
fun exampleTest() {
this.eventDetailsActivityRule.launchActivity(intent)
}
I like to explicitly grant the permissions using GrantPermissionRule after or before launching the activity. How can I do that?