Answer the question
In order to leave comments, you need to log in
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
}
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question