I have written a simple test case class and placed it in the default test directory for Android Studio: \"src/androidTest\". I\'ve created an Android Tests build configurati
The tested and the testing class should be in the same package.
But as for folders, they should be separated. So, for tests and normal sources we use different roots.
The problem is, how to set these roots. In the AS 1.5 (maybe earlier versions can do it, too), it can be done easily:
Mark Directory As ... Sources Root.Mark Directory As ... Test Sources Root.Under these roots the path to a test class must be the same as the path to the tested class from its root, for dir names along these paths define the packages and they should be the same. But you needn't worry about the structures above the roots.
Using this method you can add tests to any existing structure of sources. If you are creating the structure yourself, make it rather traditional.
Edit. Notice, that folders structure for modules of Java 9 is something ABSOLUTELY different.