The test
folder contains code (usually test code, unit tests, etc...) that runs on your local PC or laptop. The code compiled and eventually run using the installed Java on your machine the same way as pure Java projects with some minor differences. So basically the purpose of the test
folder is to test parts of application code that don't have a dependency on the Android SDK and without using an Android device. Also on the side, there's another test folder which is androidTest
, it also used for testing parts of the application but with using an Android device, meaning an actual test application is loaded on the device and it executes the tests which have a dependency on the Android SDK.
That being said, pure Java projects or code usually use resources
folder and not res
(as far I have seen while using IDEs). When compiling and then running the pure Java projects or code, the contents of the resources
folder are placed at the root of the Java classpath so that the code being executed finds its resources
there.
Android Studio or the Android Gradle Plugin seems to handle both differently (in terms of packaging them into the final aar
or apk
), so it is best that there is only res
in main
or androidTest
folder and also that there is only resources
in test
folder.