A
A
Andrew_212018-08-17 10:52:17
Android
Andrew_21, 2018-08-17 10:52:17

Why android kotlin test coverage == 0%?

Hello, tell me what could be the reason for 0% coverage of Kotlin classes?
Created a test project, it has 2 classes - java and kotlin, directory src/main/java

apply plugin: 'jacoco'

jacoco {
    toolVersion = "$jacocoVersion" // 0.8.1
}

tasks.withType(Test) {
    jacoco.includeNoLocationClasses = true
}

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: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
    def debugTreeKotlin = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
    def mainSrc = "$project.projectDir/src/main/java"

    sourceDirectories = files([mainSrc])
    classDirectories = files([debugTree], [debugTreeKotlin])
    executionData = fileTree(dir: project.buildDir, includes: [
            'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
    ])
}
android {
       ...
  testOptions {
        animationsDisabled true
        unitTests {
            includeAndroidResources = true
            all {
                jacoco {
                    includeNoLocationClasses = true
                }
            }
        }
    }
}

./gradlew createDebugCoverageReport -> and output java classes covered but not kotlin. If there is a link to a working project with code covered by Kotlin, I would be grateful. Thanks
5b767d319555d452782924.png5b767d3c92595835532343.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question