使用 Spoon 设置错误的仪器测试
Instrumentation Tests with usage of Spoon setup error
我正在尝试 运行 使用 Spoon 进行测试。
根据我在那里找到的设置指南:https://github.com/stanfy/spoon-gradle-plugin,我对我的项目进行了一些简单的更改。
首先:我在根 build.gradle 文件中添加了依赖项:
buildscript {
repositories {
jcenter()
mavenCentral()
(...)
}
dependencies {
(...)
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.0.2'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
第二:在我的应用程序包中 build.gradle 我添加了:
apply plugin: 'spoon'
和依赖:
androidTestCompile 'com.squareup.spoon:spoon-client:1.1.9'
并指定我想使用调试版本:
spoon {
debug true
}
第三步:我进入终端,将目录设置为我的项目根目录并调用
./gradlew spoon
我收到此输出和错误。可能是什么原因造成的?
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;
这为我解决了这个问题:
classpath 'com.squareup.spoon:spoon-runner:1.2.0'
classpath('com.stanfy.spoon:spoon-gradle-plugin:1.0.3') {
exclude module: "guava"
}
一些背景:
https://github.com/stanfy/spoon-gradle-plugin/issues/74
我知道是什么导致了我的案例错误。要删除:
com.android.ddmlib.IDevice.installPackage(Ljava/lang/String;Z[Ljava/lang/String;)Ljava/lang/String
我不得不更改我的 gradle 构建工具。我之前用过:
classpath 'com.android.tools.build:gradle:1.4.0-beta2'
我不得不将其更改为:
classpath 'com.android.tools.build:gradle:1.3.1'
要重现问题,您可以从 gradle-plugin git 示例项目中提取。有:
classpath 'com.android.tools.build:gradle:1.2.2'
用过。在将其更新为 1.4.0 后,它会出现与我相同的错误。我测试过:1.3.1 有效,1.4.0beta2-beta6 到目前为止出错。
编辑:
更新 runner 和 spoon 客户端后错误已修复。使用:
androidTestCompile 'com.squareup.spoon:spoon-client:1.2.1'
和
classpath 'com.squareup.spoon:spoon-runner:1.2.1'
我正在尝试 运行 使用 Spoon 进行测试。
根据我在那里找到的设置指南:https://github.com/stanfy/spoon-gradle-plugin,我对我的项目进行了一些简单的更改。
首先:我在根 build.gradle 文件中添加了依赖项:
buildscript {
repositories {
jcenter()
mavenCentral()
(...)
}
dependencies {
(...)
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.0.2'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
第二:在我的应用程序包中 build.gradle 我添加了:
apply plugin: 'spoon'
和依赖:
androidTestCompile 'com.squareup.spoon:spoon-client:1.1.9'
并指定我想使用调试版本:
spoon {
debug true
}
第三步:我进入终端,将目录设置为我的项目根目录并调用
./gradlew spoon
我收到此输出和错误。可能是什么原因造成的?
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;
这为我解决了这个问题:
classpath 'com.squareup.spoon:spoon-runner:1.2.0'
classpath('com.stanfy.spoon:spoon-gradle-plugin:1.0.3') {
exclude module: "guava"
}
一些背景: https://github.com/stanfy/spoon-gradle-plugin/issues/74
我知道是什么导致了我的案例错误。要删除:
com.android.ddmlib.IDevice.installPackage(Ljava/lang/String;Z[Ljava/lang/String;)Ljava/lang/String
我不得不更改我的 gradle 构建工具。我之前用过:
classpath 'com.android.tools.build:gradle:1.4.0-beta2'
我不得不将其更改为:
classpath 'com.android.tools.build:gradle:1.3.1'
要重现问题,您可以从 gradle-plugin git 示例项目中提取。有:
classpath 'com.android.tools.build:gradle:1.2.2'
用过。在将其更新为 1.4.0 后,它会出现与我相同的错误。我测试过:1.3.1 有效,1.4.0beta2-beta6 到目前为止出错。
编辑: 更新 runner 和 spoon 客户端后错误已修复。使用:
androidTestCompile 'com.squareup.spoon:spoon-client:1.2.1'
和
classpath 'com.squareup.spoon:spoon-runner:1.2.1'