2
我試圖讓Jacoco與咖啡的工作但是當我嘗試按照像搖籃找不到「testDebug」任務
http://raptordigital.blogspot.com/2014/08/code-coverage-reports-using-robolectric.html
爲例jacocoTestReport任務取決於「testDebug」任務,這是Gradle告訴我的,在項目中找不到。我該如何解決這個問題?
我試圖讓Jacoco與咖啡的工作但是當我嘗試按照像搖籃找不到「testDebug」任務
http://raptordigital.blogspot.com/2014/08/code-coverage-reports-using-robolectric.html
爲例jacocoTestReport任務取決於「testDebug」任務,這是Gradle告訴我的,在項目中找不到。我該如何解決這個問題?
testDebug是你單元測試的任務(假設你使用的是Android Gradle插件v1.2 +或其他單元測試插件)。你正在尋找的是connectedAndroidTest
任務或其味道。
Here是與espresso測試一起工作的完整jacocoTestReport任務。
apply plugin: 'jacoco'
jacoco {
version "0.7.1.201405082137"
}
task jacocoTestReportAndroidTest(type: JacocoReport, dependsOn: "connectedAndroidTest") {
def coverageSourceDirs = [
'src/main/java'
]
group = "Reporting"
description = "Generates Jacoco coverage reports"
reports {
csv.enabled false
xml{
enabled = true
destination "${buildDir}/reports/jacoco/jacoco.xml"
}
html{
enabled true
destination "${buildDir}/jacocoHtml"
}
}
classDirectories = fileTree(
dir: 'build/intermediates/classes',
excludes: ['**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Activity*.*',
'**/*Fragment*.*'
]
)
sourceDirectories = files(coverageSourceDirs)
additionalSourceDirs = files(coverageSourceDirs)
if (project.hasProperty('coverageFiles')) {
// convert the comma separated string to an array to create an aggregate report from
// multiple coverage.ec files
def coverageFilesArray = coverageFiles.split(',')
executionData = files(coverageFilesArray)
}
else {
executionData = files('build/outputs/code-coverage/connected/coverage.ec')
}
}
您的鏈接已中斷 – hellyale
@hellyale對不起。我更新了答案。 –
它幫助感謝 –