Hi, 
It was my mistake. I solved it and now I am able to get the coverage 
report. One thing I discovered is: for classes which uses Kotlin object 
shows 0 coverage. 

object B {
  const val ABC = 1
}

class A(c: C) {
 fun logic1() {
   var a = c.getValue(B.ABC)
}

Now class A always shows 0 coverage.

Best Regards,
Sambuddha Dhar

On Tuesday, 17 January 2023 at 15:27:05 UTC+5:30 Marc R. Hoffmann wrote:

> Hi,
>
> first of all please note that neither the Grade integration nor the 
> Android SDK JaCoCo integration is developer by us. You might better check 
> with those projects.
>
> > But I am not able to get the jacoco coverage report(xml/html) inside the 
> /build/reports/jacoco folder.
>
> So, do you get any error message? What exactly is the build log output 
> report task?
>
> Cheers,
> -marc
>
>
>
> On 17. Jan 2023, at 07:10, Sambuddha Dhar <[email protected]> wrote:
>
> Hi Team,
>
> <https://stackoverflow.com/posts/75139206/timeline>
>
> I am trying to use Jacoco Offline instrumentation in my android project to 
> get coverage with PowerMockito. Following is my build.gradle.
> apply plugin: 'jacoco'
>
> configurations {
>     jacocoAnt
>     jacocoRuntime
> }
>
> jacoco {
>     toolVersion = '0.8.8'
> }
>
> dependencies {
>     jacocoAnt group: 'org.jacoco', name: 'org.jacoco.ant', version: 
> '0.8.8', classifier: 'nodeps'
>     jacocoRuntime group: 'org.jacoco', name: 'org.jacoco.agent', version: 
> '0.8.8', classifier: 'runtime'
> }
>
> //def testTaskName = "test${sourceName.capitalize()}UnitTest"
>
> project.afterEvaluate {
>     // Grab all build types and product flavors
>     def buildTypes = android.buildTypes.collect { type -> type.name }
>     def productFlavors = android.productFlavors.collect { flavor -> 
> flavor.name }
>
>     // When no product flavors defined, use empty
>     if (!productFlavors) productFlavors.add('')
>
>     productFlavors.each { productFlavorName ->
>         buildTypes.each { buildTypeName ->
>             def sourceName, sourcePath
>             if (!productFlavorName) {
>                 sourceName = sourcePath = "${buildTypeName}"
>             } else {
>                 sourceName = 
> "${productFlavorName}${buildTypeName.capitalize()}"
>                 sourcePath = "${productFlavorName}/${buildTypeName}"
>             }
>             def testTaskName = "test${sourceName.capitalize()}UnitTest"
>
>             def excludes = ['**/R.class',
>                             ......]
>
>
>             task "${testTaskName}Instrument"() {
>                 ext.outputDir = buildDir.path + '/classes-instrumented'
>                 doLast {
>                     ant.taskdef(name: 'instrument',
>                             classname: 'org.jacoco.ant.InstrumentTask',
>                             classpath: configurations.jacocoAnt.asPath)
>                     ant.instrument(destdir: outputDir) {
>                         fileset(dir: 
> "${project.buildDir}/intermediates/javac", excludes: excludes)
>                         fileset(dir: 
> "${project.buildDir}/tmp/kotlin-classes", excludes: excludes)
>                     }
>                     testProdUnitTest.classpath = files(outputDir) + 
> testProdUnitTest.getClasspath()
>                 }
>
>             }
>
>             task "${testTaskName}Report"(type: JacocoReport) {
>                 doLast {
>                     ant.taskdef(name: 'report',
>                             classname: 'org.jacoco.ant.ReportTask',
>                             classpath: configurations.jacocoAnt.asPath)
>                     ant.report() {
>                         executiondata {
>                             ant.file(file: 
> "$buildDir.path/jacoco/testProdUnitTest.exec")
>                         }
>                         structure(name: 'Example') {
>                             classfiles {
>                                 fileset(dir: 
> "${project.buildDir}/intermediates/javac", excludes: excludes)
>                                 fileset(dir: 
> "${project.buildDir}/tmp/kotlin-classes", excludes: excludes)
>                             }
>                             sourcefiles {
>                                 fileset(dir: 'src/main/java')
>                             }
>                         }
>                         html(destdir: "$buildDir.path/reports/jacoco")
>                         xml(destdir: "$buildDir.path/reports/jacoco")
>                     }
>                 }
>
>             }
>         }
>     }
>
> }
>
> I am running - *./gradlew testProdUnitTestReport*
> The instrumented class folder is created properly. But I am not able to 
> get the jacoco coverage report(xml/html) inside the /build/reports/jacoco 
> folder. Please help me by pointing out what I am doing wrong here. Thanks 
> in advance
>
> Bets Regards,
> Sambuddha Dhar
>
>
> -- 
> 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/63c9d9da-2626-4d1a-b28d-b463153540c1n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jacoco/63c9d9da-2626-4d1a-b28d-b463153540c1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
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/0b40a026-bbbe-4a9e-9fe2-119cf663ca50n%40googlegroups.com.

Reply via email to