Here is a self-contained reduced testcase of the s...
# mockk
j
Here is a self-contained reduced testcase of the scenario:
Copy code
package org.example

import io.kotest.core.spec.style.ShouldSpec
import io.kotest.matchers.shouldBe
import io.mockk.every
import io.mockk.spyk

@JvmInline
value class LongWrapper(val value: Long)

class StateHolder() {
    var state = -1L

    fun setState(v: LongWrapper?) {
        state = v?.value ?: -1L
    }

    fun getState(): LongWrapper? {
        return if (state < 0) { null } else {
            LongWrapper(state)
        }
    }
}

class MockTest: ShouldSpec() {
    init {
        context("Mocking a function") {
            should("work correctly") {
                val mockObj = spyk<StateHolder>()

                every { mockObj.getState() } returns LongWrapper(42)

                mockObj.getState() shouldBe LongWrapper(42)
            }
        }
    }
}