Get Local Android Testing Resources
When running standard junit tests (not AndroidTestCase) in Android, how can I get the resources in src / test / resources ?
I've tried all the usual ...
getClass().getResourceAsStream("/testData.dat");
and...
Thread.currentThread().getContextClassLoader() .getResourceAsStream("/testData.dat");
and also with gradle copy resources.
task copyTestResources (type: Copy) {from "$ {projectDir} / src / test / resources" to "$ {buildDir} / classes / test"}
Which confuses me when I ask in a unit test what the classloaders path to get resources uses
ClassLoader classLoader = Thread.currentThread (). getContextClassLoader (); URL resource = classLoader.getResource (".");
It returns: / home / rob / Android / Sdk / platform / android-17 / data / res
Can someone explain this to me and tell me how I can get the relative path anywhere in the project so that I can use the test resources?
source to share
No one has answered this question yet
Check out similar questions: