Issue
I'm configuring a workflow in Bitrise to run my instrumentation tests for an Android project. I don't know why but the AndroidTest resource directory is not available during Bitrise ui tests. I have this in my build.gradle
sourceSets {
androidTest {
resources.srcDirs += ['src/AndroidTest/assets']
}
}
and I'm doing this to load the assets from my tests:
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(filename);
This is working smoothly locally but in Bitrise the assets are not found. Any idea about this issue?
Thanks!
Solution
I found a workaround to solve the problem. Instead of add the resources inside src/AndroidTest/assets I created a new assets folder just for the debug build variant:
In this case, I don't need anymore to add the assets as an additional folder because it will be already included inside the test apk. Using the debug build variant this folder will not be included inside the release apk so this solution works fine for me.
The only difference is that now in order to load the resources I need to do it through the context inside my test in the following way:
InputStream inputStream = InstrumentationRegistry.getTargetContext().getAssets().open("mock/" + filename);
Answered By - rdiaz82

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.