Skip to content

Code coverage incorrect for Kotlin data classes with kotlinx.serialization in JaCoCo 0.8.13 #1855

@Dukoff92

Description

@Dukoff92

I am experiencing incorrect code coverage when using JaCoCo version 0.8.13 with Kotlin data classes that utilize kotlinx.serialization. It appears that generated parameters and functions are not properly excluded from coverage, which leads to incorrect results.

This issue did not occur in version 0.8.12, where the coverage was reported correctly.

Steps to Reproduce:
gradle version: 8.12.1
kotlin version: 2.1.10
Use Kotlin data classes with kotlinx.serialization
Run JaCoCo with version 0.8.13

Example data class:

@Serializable
data class User(
    @SerialName("name")
    val name: String? = null,

    @SerialName("age")
    val age: Int? = null
)

Expected behavior:
Generated serialization-related code should be excluded from the coverage report, as it was in version 0.8.12

Actual Behavior:
The report includes functions and constructors that should be excluded or covered
Coverage for these generated elements is reported as 0%

Version 0.8.13
Image

Version 0.8.12
Image

Metadata

Metadata

Assignees

Labels

language: KotlinTickets about Kotlin language supporttype: bug 🐛Something isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions