I'm playing with Gradle for Android recently... It's powerful but painful at the same time.
Initially, I followed Roboletric sample project, trying to make a gradle-based Android project with Robolectric testing support. After a while, I realise Robolectric doesn't even support API 19. Thus, I remove it from my build.gradle and try to use Junit and Instrumentation tests.
I'm not familiar with either Android or Gradle or Roboletric. I only know that before I removed Robolectirc, whenever I made a build ./gradlew clean build
I was able to run all the tests. But now, I have to call ./gradlew connectedAndroidTest
in addition to run tests while the build
command only calls check
but no test is run and thus always show SUCCESSFUL
I have attached my configuration here:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
packageName "com.example"
testPackageName "com.example.tests"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
flavorDimensions "AppPackage", "AppEnvironment"
appBasic {
flavorDimension "AppPackage"
}
staging {
flavorDimension "AppEnvironment"
}
production {
flavorDimension "AppEnvironment"
}
}
sourceSets {
androidTest.setRoot('src/test')
androidTestStaging.setRoot('src/testStaging')
androidTestProduction.setRoot('src/testProduction')
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
}