I'm using Android Studio version 0.8.14. Currently, after creating a new Android project, by default the test source code folder androidTest
is located inside the src
folder of the app
module, at the same level as main
(which contains application source code).
But if, for any particular reason, I want to move the test code into a separate module in my project, or even further, into a separate project other than the project I'm using for application source code, can I do this?
To make it easier for you to understand what I'm asking, a 'picture' would be better. The current default new project structure which Android Studio create is something looks like this:
My Project
|___my app module
|___src
|___androidTest
|___main
Now I want something looks like this:
My Project
|___my app module
| |___src
| |___main
|___my test module
or this:
My App Project
| |___my app module
|
My Test Project (some how linked to My App Project)
How can I get this? Any help would be appreciated.
If I understand what you are asking, the bit of information that you might be missing is to add something like:
to your settings.gradle file. I use this technique to separate out my 'connected' tests from pure unit tests. You might be interested in checking out a fork that I made of the popular deckard-gradle project that does exactly this: https://github.com/jdonmoyer/deckard-gradle
The technique for specifying a test directory other than "androidTest" is to add a "sourceSets" configuration option to the "build.gradle" file as shown below:
The above example would only change the name of the test directory from "androidTest" to "test".
But you could try the same technique using a relative or full path name such as
or