[英]unable to get test coverage report in Espresso
Unable to get Espresso Code coverage report, i am new to android studio and tried following set up for generating the report .无法获得 Espresso 代码覆盖率报告,我是 android studio 的新手,并尝试按照设置生成报告。
Please find the build.gradle setting:请找到 build.gradle 设置:
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'realm-android'
apply plugin: 'jacoco'
buildTypes {
debug {
debuggable true
minifyEnabled false
multiDexEnabled true
testCoverageEnabled true
}
When i run the recorded test with 'CreateDebugAndroidTestCoverage', i get the following Report:当我使用“CreateDebugAndroidTestCoverage”运行记录的测试时,我得到以下报告:
I am expecting columns with methods, line details etc :我期待带有方法、行详细信息等的列:
Please find the screen shot for the type of report i am expecting :请找到我期望的报告类型的屏幕截图:
You need to add configurations for jacoco report by creating a task in your module's Gradle file (Generally, app/build.gradle
).您需要通过在模块的 Gradle 文件(通常为
app/build.gradle
)中创建一个任务来为 jacoco 报告添加配置。 And in that task, you need to add createDebugCoverageReport
for depnedsOn
property.在该任务中,您需要为
depnedsOn
属性添加createDebugCoverageReport
。 Let me show you an example of how does it look:让我向您展示它的外观示例:
// Task declaration
task jacocoTestReport(type: JacocoReport) {
// Runs only after the dependencies are executed
dependsOn = ['testDebugUnitTest', 'createDebugCoverageReport']
// Export formats
reports {
xml.enabled = true
html.enabled = true
}
sourceDirectories.from = files(coverageSourceDirs)
classDirectories.from = fileTree(
dir: './build/intermediates/classes/debug',
excludes: ['**/R*.class'
])
// Inform Gradle where the files generated by test cases - are located
executionData.from = fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec',
'outputs/code_coverage/debugAndroidTest/connected/*.ec'
])
}
Now, you can run this task with coverage and it will provide you the coverage.现在,您可以在覆盖范围内运行此任务,它将为您提供覆盖范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.