samedi 7 mars 2015

How to read a test-only file in Android unit test

For my Android app I'm writing unit tests that require reading some files. Since those are test-only files I don't want them in my res folders as I don't want them to end up in my final .apk file.


I want to do something similar to this question but using the newly added (in Gradle 1.1) unit test support (as opposed to instrumentation test).


My project structure is as follows:



/app
/src
/main
/java/my.module/myClass.java
/res/production_resources_go_here
/test
/java/my.module/myClassTest.java
/resources/testFile.txt


what should my myClassTest test look like to be able to successfully read the testFile.txt?


Aucun commentaire:

Enregistrer un commentaire