-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Kotlin generates additional classes when using reflection. These classes are neither marked as covered nor filtered out by jacoco.
Steps to reproduce
Add maven dependency
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>
and create a function which gets a reflect.Method reference to a function like this:
fun minimalFunction() {
// this will make jacoco fail due to a class generated by kotlin
::minimalFunction.javaMethod
}
when using .javaMethod
, Kotlin generates an anonymous class which will be checked for line coverage by jacoco
JaCoCo version: 0.8.2
Operating system: any (tested on Mac OS 10.13.6 and Ubuntu)
Tool integration: Maven
Expected behaviour
Code generated by Kotlin compiler should be marked as covered or filtered out
Actual behaviour
Line coverage for generated class is 0.00
Rule violated for class SomeController.getAddressWithGeoInformation.javaMethod.1: lines covered ratio is 0.00, but expected minimum is 0.85
This issue may or may not affect other reflection mechanisms as well. I tested only .javaMethod
as we use this for generating HATEOAS links in our web controller classes.
Metadata
Metadata
Assignees
Type
Projects
Status