Jacoco setting seems ok Just add 

buildTypes {
        debug {
            enableUnitTestCoverage true
            enableAndroidTestCoverage true
        }
    }

and report command is 
.\gradlew create{YOUR_TASK}CoverageReport
On Thursday, September 22, 2022 at 9:57:58 PM UTC+9 Kanishak Gupta wrote:

> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/b506edb1-58bb-4de9-875a-3fa7f16e8ce0n%40googlegroups.com.

Reply via email to