I am trying to run my tests with usage of Spoon.
According to setup guide I found there: https://github.com/stanfy/spoon-gradle-plugin , I've set few simple changes to my project.
First: I've added dependency in my root build.gradle file:
buildscript {
repositories {
jcenter()
mavenCentral()
(...)
}
dependencies {
(...)
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.0.2'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
Second: in my app package build.gradle I've added:
apply plugin: 'spoon'
And dependency:
androidTestCompile 'com.squareup.spoon:spoon-client:1.1.9'
And specified that I want to use debug builds:
spoon {
debug true
}
Third: I go to terminal, set directory to my project root and invoke
./gradlew spoon
I receive this output and error. What may be causing this?
2015-10-20 17:28:12 [SR.runTests] Executing instrumentation suite on 1 device(s).
2015-10-20 17:28:12 [SR.runTests] Application: com.azimo.sendmoney.debug1 from /Users/F1sherKK/Dev/Azimo-Android/app/build/outputs/apk/app-debug.apk
2015-10-20 17:28:12 [SR.runTests] Instrumentation: com.azimo.sendmoney.debug1.test from /Users/F1sherKK/Dev/Azimo-Android/app/build/outputs/apk/app-debug-androidTest-unaligned.apk
2015-10-20 17:28:12 [SR.runTests] [1903cdc7] Starting execution.
2015-10-20 17:28:12 [SDR.run] InstrumentationInfo: [com.squareup.spoon.SpoonInstrumentationInfo@7baf516e[applicationPackage=com.azimo.sendmoney.debug1,instrumentationPackage=com.azimo.sendmoney.debug1.test,testRunnerClass=android.support.test.runner.AndroidJUnitRunner]]
2015-10-20 17:28:12 [SDR.run] Got realDevice for [1903cdc7]
2015-10-20 17:28:12 [SDR.run] [1903cdc7] setDeviceDetails com.squareup.spoon.DeviceDetails@22444900[model=GT-I9505,manufacturer=samsung,version=5.0.1,apiLevel=21,language=en,region=GB,isEmulator=false,avdName=<null>]
2015-10-20 17:28:12 [SR.runTests] [1903cdc7] Execution done.
:app:spoonDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:spoonDebugAndroidTest'.
> com.android.ddmlib.IDevice.installPackage(Ljava/lang/String;Z[Ljava/lang/String;)Ljava/lang/String;
I know what caused error in my case. To delete:
com.android.ddmlib.IDevice.installPackage(Ljava/lang/String;Z[Ljava/lang/String;)Ljava/lang/String
I had to change my gradle build tools. I was using before:
classpath 'com.android.tools.build:gradle:1.4.0-beta2'
I had to change it to:
classpath 'com.android.tools.build:gradle:1.3.1'
To recreate the problem you can pull from gradle-plugin git example project. There is:
classpath 'com.android.tools.build:gradle:1.2.2'
used. And after you update it to 1.4.0 it gives same error as I have. I tested: 1.3.1 works, 1.4.0beta2-beta6 gives error so far.
Edit: Error was fixed after update of runner and spoon client. Use:
androidTestCompile 'com.squareup.spoon:spoon-client:1.2.1'
and
classpath 'com.squareup.spoon:spoon-runner:1.2.1'