I'm seeing behavior I am not expecting during development of android library (AAR), was wondering if someone can explain it. my library structure is :
src/
androidTest/
assets/
my_assets/
java/
com/
...
main/
java/
com/
...
my test is doing the following:
final String assetsSubfolder = "my_assets";
Context targetContext = InstrumentationRegistry.getTargetContext();
String[] targetAssets = targetContext.getResources().getAssets().list("");
Context testContext = InstrumentationRegistry.getContext();
String[] testAssets = testContext.getResources().getAssets().list("");
Assert.assertTrue("target should not have assets now", !Arrays.asList(targetAssets).contains(assetsSubfolder));
Assert.assertTrue("test should have assets now", Arrays.asList(testAssets).contains(assetsSubfolder));
The test fails due to the target, which is the library production code, containing my testing assets folder. I thought that using getTargetContext I will see no assets folder, as there is no assets folder in my production code. Can someone explain this?