I've seen a lot of tutorials and helper projects for doing testing on an Android Studio / Gradle project. I'm curious about the naming convention of the the test folder. I've seen two similar namings : test
and androidTest
. Is there any real difference? Is the IDE / Gradle framework treating these differently?
- app
- src
- androidTest
- java
- main
- java
- res
- androidTest
- src
versus
- app
- src
- test
- java
- main
- java
- res
- test
- src
EDIT:
@jonalmeida So if I read that documentation correctly, my build.gradle
file dependencies need to match the sourceSet, right?
dependencies {
// dependency injection
compile 'com.squareup.dagger:dagger:1.2.1'
provided 'com.squareup.dagger:dagger-compiler:1.2.1'
// networking
compile 'com.squareup.retrofit:retrofit:1.6.1'
// testing
androidTestCompile 'org.easytesting:fest:1.0.16'
androidTestCompile 'junit:junit:4.+'
androidTestCompile 'org.robolectric:robolectric:2.3'
testCompile 'com.squareup:fest-android:1.0.8' // <---- this guy won't work
}
Since Android Studio 1.1 you should put your Unit tests in
/src/test
and Android Instrumentation Tests in/src/androidTest
See: http://tools.android.com/tech-docs/unit-testing-support#TOC-Setting-up-Android-Studio
For Android Studio 2.0 and beyond see: https://youtu.be/kL3MCQV2M2s?t=114
In Android Studio the convention to follow for tests is to use
androidTest
. You can find more details documented on the Android Tools site.