Hi all,
I am trying to generate the code coverage for our android project. It comprises of both Unit test cases and Instrument Test Cases. But the coverage is generated only for Unit tests.
In the html file, the Activity names are present, but the coverage is always zero. Could someone please help me figure out the issue, so that the UI test cases also reflect a coverage.
Please find below the build.gradle implementation and gradle commands.
'''
task jacocoTestReport(type: JacocoReport, dependsOn: ["testDebugUnitTest", "createDebugAndroidTestCoverageReport", "connectedAndroidTest"]) {
group = "Reporting"
description = "Generate Jacoco coverage reports"
reports {
xml.required = true
html.required = true
}
def fileFilter = ['**/AndroidManifest.xml', '**/strings.xml', '**/*.xml', '**/*.json']
def mainSrc = "${project.projectDir}"
def kotlinTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debugUnitTest", excludes: fileFilter)
def kotlinUITree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debugAndroidTest", excludes: fileFilter)
sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([kotlinTree, kotlinUITree]))
executionData.setFrom(fileTree(dir: "$project.buildDir",
includes: ['**/*.exec', '**/*.ec']
))
}
'''
gradlew connectedAndroidTest jacocoTestReport
Thank you in advance.