Issue
Currently, I'm storing the same resources in
/test/resources/sample.txt //for unit tests
/main/asssets/sample.txt //for espresso tests
can I store them in one place? If yes, how can I read them in my tests? Preferably, I would like to open them as the File object, not InputStream.
Solution
So, I finally decided that the best solution, in this case, is to store everything in assets folder (in mock flavor).
You can open them from instrumentation test:
activityRule.activity.assets.open("sample.txt")
from unit tests:
private val ASSET_BASE_PATH = "../app/src/mock/assets/"
fun openAsset(filename: String): InputStream {
return FileInputStream(ASSET_BASE_PATH + filename)
Answered By - qbait
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.