嗨,我已经在 Jenkins 上建立了我的 Android 项目来提供 CI。它运行良好,在连接的 Android 手机上运行测试。测试在扩展 jUnit3 的 Android 测试框架上运行。
不幸的是,如果有任何测试失败,构建将被标记为失败。我希望能够通过两种方式改进这一点:
- 允许不稳定的构建
- 能够标记已知的测试失败
对于第 1 项,我尝试将其添加到项目 build.gradle 中:
connectedCheck {
ignoreFailures = true
}
但它没有效果。查看构建日志,我意识到实际的测试任务叫做connectedInstrumentTest,但是没有找到这个任务:
connectedInstrumentTest {
ignoreFailures = true
}
原因:
在项目“:Playtime”上找不到参数 [build_4ldpah0qgf0ukktofecsq41r98$_run_closure3@9cd826] 的方法 connectedInstrumentTest()。
那是我失踪了吗?
谢谢
编辑:继承我的项目 build.gradle,没什么特别的:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
testPackageName "com.bb.pt.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
}
connectedCheck {
ignoreFailures = true
}
我在詹金斯的 gradle 设置:
switches: --stacktrace --info
tasks: :pt:assembleDebug :pt:assembleTest :pt:connectedCheck
编辑:
我建立了 gradlew 并尝试了。相同的输出。如果测试失败,我不希望构建失败:
:pt:connectedInstrumentTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':pt:connectedInstrumentTest'.
> There were failing tests. See the report at: file:///home/simon/WorkingCopies/bb/code/trunk/pt/pt/build/reports/instrumentTests/connected/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
我试图在 build.gradle 中限定任务名称:
task connectedCheck {
ignoreFailures = true
}
但它认为我正在尝试添加新任务而不是修改现有任务。
FAILURE: Build failed with an exception.
* Where:
Build file '/home/simon/WorkingCopies/bb/code/trunk/pt/pt/build.gradle' line: 31
* What went wrong:
A problem occurred evaluating project ':pt'.
> Cannot add task ':pt:connectedCheck' as a task with that name already exists.