Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Coverage report is not correct for Kotlin inline function and inline function with reified parameter in 0.8.13 #1873

@chapp-hk

Description

@chapp-hk

Steps to reproduce

  • JaCoCo version: 0.8.13.202504020838
  • Operating system:
  • Tool integration: Maven / Ant / CLI / API (for others please report to respective project)
  • Complete executable reproducer: (e.g. GitHub Repo)
  • Steps: (what exactly are you doing with the above reproducer?)
// The functions
package com.example.myapplication

fun addString(first: String, second: String): String {
    return first + second
}

inline fun <reified T> add(first: T, second: T): String {
    return first.toString() + second.toString()
}

inline fun inlineFun(inlined: () -> Unit, noinline notInlined: () -> Unit) {
    inlined()
    notInlined()
}
// The tests
package com.example.myapplication

import io.mockk.mockk
import io.mockk.verifySequence
import org.junit.Assert.assertEquals
import org.junit.Test

class MyKtxKtTest {
    @Test
    fun `test addString`() {
        assertEquals(addString("123", "789"), "123789")
    }

    @Test
    fun `test add`() {
        assertEquals(add<String>("1", "2"), "12")
    }

    @Test
    fun `test inlineFun`() {
        val mockInlined = mockk<() -> Unit>(relaxed = true)
        val mockNotInlined = mockk<() -> Unit>(relaxed = true)

        inlineFun(
            inlined = mockInlined,
            notInlined = mockNotInlined
        )

        verifySequence {
            mockInlined()
            mockNotInlined()
        }
    }
}

Expected behaviour

  • Coverage report should show 100% covered

Actual behaviour

  • The report shows add() and inlineFun() are not covered with red highlight
Image

(In case of exceptions provide FULL STACKTRACE)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions