mercredi 27 avril 2016

cannot read external storage in android unit test

Trying to access "android.os.Environment.getExternalStorageState()" in an android unit test(annotated with @Test) results in null because according to http://ift.tt/1NBEu0w they want you to only test your code.

My code reads from external storage, so I need this value. This test broke(it used to work, probably with an older version of the build tools). Adding the suggested:

android {
testOptions { 
  unitTests.returnDefaultValues = true
}
}

in the module's build.gradle still produces null. How do I open the test artifacts section of the IDE?

Aucun commentaire:

Enregistrer un commentaire