New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic private function mocking #70

oleksiyp opened this Issue May 3, 2018 · 3 comments


2 participants

oleksiyp commented May 3, 2018

Expected Behavior

  • generic function private calls are callable

Current Behavior

  • error happens

Failure Information (for bugs)

Stack trace

io.mockk.MockKException: can't find function updateItemInDb(-6386956503980247280, -707b0625140c5671,$ByteBuddy$woSXx9ac$ByteBuddy$8Oi0CU86@63e5e5b4) for dynamic call

	at io.mockk.InternalPlatformDsl.dynamicCall(InternalPlatformDsl.kt:109)
	at io.mockk.MockKMatcherScope$DynamicCall.invoke(API.kt:1546)
	at io.mockk.impl.eval.RecordedBlockEvaluator$record$block$1.invoke(RecordedBlockEvaluator.kt:22)
	at io.mockk.impl.recording.JvmAutoHinter.autoHint(JvmAutoHinter.kt:23)
	at io.mockk.impl.eval.RecordedBlockEvaluator.record(RecordedBlockEvaluator.kt:31)
	at io.mockk.impl.eval.EveryBlockEvaluator.every(EveryBlockEvaluator.kt:25)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(
	at org.junit.runners.ParentRunner.runLeaf(
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
	at org.junit.runners.ParentRunner$
	at org.junit.runners.ParentRunner$1.schedule(
	at org.junit.runners.ParentRunner.runChildren(
	at org.junit.runners.ParentRunner.access$000(
	at org.junit.runners.ParentRunner$2.evaluate(
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(
	at com.intellij.rt.execution.junit.JUnitStarter.main(

Minimal reproducible code (the gist of this issue)


import io.mockk.*
import kotlin.test.Test

class Issue70Test {
    class Cls {
        private fun <T> updateItemInDb(id: Long, column: String, data: T) {

        fun pubCall() {
            updateItemInDb(1L, "abc", "data")

    fun test() {
        val mock = spyk<Cls>();

        every {
            mock["updateItemInDb"](any<Long>(), any<String>(), any<Any>())  as Unit
        } just Runs



@oleksiyp oleksiyp added the bug label May 3, 2018

oleksiyp added a commit that referenced this issue May 3, 2018


This comment has been minimized.


oleksiyp commented May 3, 2018

So basically I fixed the issue. Currently, I am busy with doing android instrumentation tests working. Will decide later if it goes to version 1.8 with instrumentation test or just 1.7.16 alone.


This comment has been minimized.


oleksiyp commented May 6, 2018

Released 1.7.16. Issue should be fixed there. Please check and close issue if it is fixed.


This comment has been minimized.

MrAlexSee commented May 7, 2018

Works fine, thanks (I'm not able to close the issue).

@oleksiyp oleksiyp closed this May 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment