a

    Akhil Sunny

    2 years ago
    Hi , I have a kotlin mpp with android, js and iOS outputs. Could you please suggest the unit testing code coverage tools I can use for Kotlin mpp project ?
    v

    verachadw

    2 years ago
    AFAIK, There is no code coverage tools that support Kotlin MPP project at the moment.
    e

    EvaS

    2 years ago
    We use Jacoco
    a

    Akhil Sunny

    2 years ago
    @EvaS - Can you please share an example ?. Looking online . I can see jacoco being used for Kotlin java project. but can't find any for a Kotlin app with js, ios and android outputs
    e

    EvaS

    2 years ago
    Actually we don't use JS, still we have a
    .gradle
    looking like that :
    apply plugin: 'jacoco'
    jacoco {
        toolVersion = "0.8.3"
    }
    
    task jacocoTestReport(type: JacocoReport, dependsOn: "testDebugUnitTest") {
        group = "Reporting"
        description = "Generate Jacoco coverage reports after running tests."
        reports {
            xml.enabled = true
            html.enabled = true
        }
    
        classDirectories = fileTree(
                dir: "$project.buildDir/tmp/kotlin-classes/debug/my-package",
                excludes: [/some/path/irrevelant]
        )
    
        sourceDirectories = files('src/commonMain/kotlin')
        executionData = files("$project.buildDir/jacoco/testDebugUnitTest.exec")
    }
    Then, we just have to launch
    jacocoTestReport