On Wednesday, August 2, 2017 at 11:17:16 PM UTC+5:30, [email protected] wrote: > Hi all, > > I am trying to check my code coverage for a test case that I wrote in Kotlin. > When I execute ./gradlew createDebugCoverageReport --info, my coverage.ec > file is empty and my reports indicate that I have 0% coverage. Please note, > the test cases are 100% successful. Can anyone think of any reasons my > coverage.ec file keeps returning 0 bytes? > > I have searched everywhere with no luck. > > apply plugin: 'com.android.library' > > apply plugin: 'kotlin-android' > > apply plugin: 'kotlin-android-extensions' > > apply plugin: 'jacoco' > > > android { > compileSdkVersion 25 > buildToolsVersion "25.0.3" > defaultConfig { > minSdkVersion 16 > targetSdkVersion 25 > versionCode 1 > versionName "1.0" > testInstrumentationRunner > "android.support.test.runner.AndroidJUnitRunner" > } > > buildTypes { > debug { > testCoverageEnabled = true > } > release { > minifyEnabled false > testCoverageEnabled = true > proguardFiles getDefaultProguardFile('proguard-android.txt'), > 'proguard-rules.pro' > } > } > > > testOptions { > unitTests.all { > jacoco { > includeNoLocationClasses = true > } > } > } > > } > > dependencies { > implementation fileTree(include: ['*.jar'], dir: 'libs') > > androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', > { > exclude group: 'com.android.support', module: 'support-annotations' > }) > implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" > implementation 'com.android.support:appcompat-v7:25.4.0' > testImplementation 'junit:junit:4.12' > implementation files('pathtosomejarfile') > > } > > > > jacoco { > toolVersion = "0.7.6.201602180812" > reportsDir = file("$buildDir/customJacocoReportDir") > > } > > > > task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', > 'createDebugCoverageReport']) { > > reports { > xml.enabled = true > html.enabled = true > } > > def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', > '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*'] > def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", > excludes: fileFilter) > def mainSrc = "${project.projectDir}/src/androidTest/java" > > sourceDirectories = files([mainSrc]) > classDirectories = files([debugTree]) > executionData = fileTree(dir: "$buildDir", includes: [ > "jacoco/testDebugUnitTest.exec", > "outputs/code-coverage/connected/*coverage.ec" > ]) > }
Hi, We were working on this some times back and realized that not much help is available in internet over this issue. Feel free to check out our solution here: http://www.qalearningguide.com/2017/10/code-coverage-for-android-using-jacoco.html Thanks, Suparna -- 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/998b5aac-e2e8-44c3-9f07-b0b1b43cbb7b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
