How to change android.permission settings when running tests

Question

I am working on a third-party library that uses geolocation if the 1st party library has granted permissions. I would like to check the behavior, but I can not send my application with the permissions set in the manifest (b / c, then it will not be optional).

Is there any way to install, for example <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />, only when I run tests?

More details

I use gradle build tools com.android.tools.build:gradle:0.12.2and followed the androidTest directory convention. My project is as follows:

tree src -L 3 src ├── androidTest │   ├── java │   │   └── com │   └── resources └── main ├── AndroidManifest.xml └── java └── com

I tried adding a second manifest to the androidTest folder (I updated the package, which will be: package = "com.myapp.test"), but geo-permissions do not take effect.

robolectric, Instrumentation . , , .

+4
1

( IMO):

<appname>/build.gradle:

android {
  ...
  sourceSets {
    debug {
      manifest.srcFile 'src/androidTest/AndroidManifest.xml'
    }
  }
  ...
}

, , AndroidManifest.xml src/androidTest/ .
Android.

+4

All Articles