I'm setting up Android app structure with Gradle and Android Studio and Espresso UI testing for a project.
No matter what I try, the androidTest folder never appears in AndroidStudio's project structure.
Project (root) build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
}
}
allprojects {
repositories {
mavenCentral()
}
}
App build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "es.unizar.vv.mobile.catmdedit.app"
minSdkVersion 16
targetSdkVersion 16
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/resources'
}
res.srcDirs = ['res']
}
test.setRoot("test")
androidTest.setRoot("androidTest")
}
}
dependencies {
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
}
How project structure looks:
How project structure actually is:
Change the Test Artifact within your Build Variants to Android Instrumentation Tests.
The Build Variants tab can be found in the bottom left side of the Android Studio window above Favorites. Clicking on the tab should open a pane with your modules and build variants for those modules. Above the modules is a Test Artifact dropdown which you should change to Android Instrumentation Tests.