Issue
While running Espresso test with Android studio, I receive an exception while writing to internal storage: java.io.FileNotFoundException: /storage/emulated/0/MyCache: open failed: EACCES (Permission denied)
I do understand that this issue caused by lack of permissions.
My question is, do I have to create additional AndroidManifest file for Espresso test or should I use an existing AndroidManifest file from the app itself? I've tried the 2nd option, but it seems that MainActivityTest is not visible by my app's AndroidManifest.xml
Please refer to attached print screen:
Solution
It is possible to access application under test (AUT) context by InstrumentationRegistry.getTargetContext()
. So if you have declared needed permission in your AUT then you can use it's context.
Other possibility is to save your cache file inside AUT or test application package storage - data/data/com.your.package/files/cache_file
. Then you don't need a permission at all.
Answered By - denys
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.