title: How to manage Runtime permissions android marshmallow espresso tests
body: <p>I'm using espresso for testing but sometimes I try to get an image form external storage and with marshmallow I need a Runtime permission otherwise there will be an Exception crash and the test will fail. </p>
  
  <pre><code>androidTestCompile 'com.android.support.test:runner:0.4'
  androidTestCompile 'com.android.support.test:rules:0.4'
  androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
  androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
  androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
      // this library uses the newest app compat v22 but the espresso contrib still v21.
      // you have to specifically exclude the older versions of the contrib library or
      // there will be some conflicts
      exclude group: 'com.android.support', module: 'appcompat'
      exclude group: 'com.android.support', module: 'support-v4'
      exclude module: 'recyclerview-v7'
  }
  androidTestCompile 'junit:junit:4.12'
  androidTestCompile 'com.squareup.retrofit:retrofit-mock:1.9.0'
  androidTestCompile 'com.squareup.assertj:assertj-android:1.1.0'
  androidTestCompile 'com.squareup.spoon:spoon-client:1.2.0'
  </code></pre>
  
  <p>how can I manage that right? </p>
  
  <p>should I write test for Runtime permissions or there's a way to disable it for testing? </p>
  
  <p>should I give permissions before the tests run like she says here? <a href="https://www.youtube.com/watch?list=PLWz5rJ2EKKc-lJo_RGGXL2Psr8vVCTWjM&amp;v=C8lUdPVSzDk" rel="noreferrer">https://www.youtube.com/watch?list=PLWz5rJ2EKKc-lJo_RGGXL2Psr8vVCTWjM&amp;v=C8lUdPVSzDk</a></p>