Reputation: 269
I'm using AndroidStudio and build with gradle.
I want to test my app with Robolectirc, so I add below in build.gradle
buildscript's dependencies section:
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.+'
Apply the android-test plugin:
apply plugin: 'android-test'
Add test-only dependencies using the testCompile configuration:
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.1.+'
testCompile 'com.squareup:fest-android:1.0.+'
These are from https://github.com/JakeWharton/gradle-android-test-plugin
so I added these stuff, I get gradle.build like below.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.+'
}
}
apply plugin: 'android'
apply plugin: 'android-test'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
signingConfigs {
freeConfing {
storeFile file("../../../workspace_android/keystore/pm.keystore");
storePassword "password"
keyAlias "key"
keyPassword "password"
}
paidConfing {
storeFile file("../../../workspace_android/keystore/pm.keystore");
storePassword "password"
keyAlias "key"
keyPassword "password"
}
}
productFlavors {
paid {
packageName "com.my.app"
buildConfig "public final static boolean isFullVersion = true;"
versionCode 2
versionName "1.0.0"
signingConfig signingConfigs.paidConfing
}
free {
packageName "com.my.app"
buildConfig "public final static boolean isFullVersion = false;"
versionCode 2
versionName "1.0.0"
signingConfig signingConfigs.freeConfing
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.1.+'
testCompile 'com.squareup:fest-android:1.0.+'
}
I want to test my app so, I typed in terminal like
gradle test
but, I got
Could not determine the dependencies of task ':MyApp:testFreeDebug'.
The product flavor name is changed testFreeDebug
and gradle tasks
also not working...
Before I didn't add test stuff, it was good working.
How can I test my app with robolectric?
Upvotes: 1
Views: 1973
Reputation: 165
Try using the latest snapshot of the plugin.
buildscript {
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
}
}
Upvotes: 5