mirror of
https://github.com/torlando-tech/columba.git
synced 2025-12-22 05:37:07 +00:00
fix(coverage): enable JaCoCo coverage for Robolectric/Compose tests
- Upgrade JaCoCo from 0.8.12 to 0.8.14 (includes Compose bytecode filtering) - Add includeNoLocationClasses=true for Robolectric test coverage - Add jdk.internal.* exclusion for Java 9+ compatibility - Use ASM-transformed classes for coverage report This fixes the issue where Compose UI tests showed 0% coverage despite passing tests. The combination of JaCoCo 0.8.14 and includeNoLocationClasses enables proper coverage tracking for Robolectric-based Compose tests. Sources: - https://github.com/jacoco/jacoco/releases/tag/v0.8.14 - https://github.com/robolectric/robolectric/issues/2230 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -170,6 +170,12 @@ android {
|
||||
isReturnDefaultValues = true
|
||||
all {
|
||||
it.maxHeapSize = "2048m"
|
||||
// Enable JaCoCo coverage for Robolectric tests
|
||||
it.extensions.configure<JacocoTaskExtension> {
|
||||
isIncludeNoLocationClasses = true
|
||||
// Required for Java 9+ compatibility
|
||||
excludes = listOf("jdk.internal.*")
|
||||
}
|
||||
// Exclude Compose UI tests from release builds due to Robolectric manifest issues
|
||||
// These tests run successfully in debug and don't need to run twice
|
||||
if (it.name.contains("Release")) {
|
||||
|
||||
@@ -21,7 +21,7 @@ subprojects {
|
||||
apply(plugin = "io.gitlab.arturbosch.detekt")
|
||||
|
||||
configure<JacocoPluginExtension> {
|
||||
toolVersion = "0.8.12"
|
||||
toolVersion = "0.8.14"
|
||||
}
|
||||
|
||||
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
|
||||
@@ -106,8 +106,8 @@ tasks.register("jacocoTestReport", JacocoReport::class) {
|
||||
|
||||
// Add patterns for class directories and exec data (resolved at execution time)
|
||||
val buildDir = subproject.layout.buildDirectory.get().asFile
|
||||
classDirectoriesList.add(File("$buildDir/intermediates/javac/debug/classes"))
|
||||
classDirectoriesList.add(File("$buildDir/tmp/kotlin-classes/debug"))
|
||||
// Use ASM-transformed classes which contain all classes including UI/Compose
|
||||
classDirectoriesList.add(File("$buildDir/intermediates/classes/debug/transformDebugClassesWithAsm/dirs"))
|
||||
// Android puts coverage data in outputs/unit_test_code_coverage/
|
||||
execDataPatterns.add("$buildDir/outputs/unit_test_code_coverage/debugUnitTest")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user