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

Closed
oleksiyp opened this Issue May 3, 2018 · 3 comments

Comments

2 participants
@oleksiyp
Collaborator

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, net.bytebuddy.renamed.java.lang.Object$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.gh.Issue70Test$test$1.invoke(Issue70Test.kt:34)
	at io.mockk.gh.Issue70Test$test$1.invoke(Issue70Test.kt:6)
	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 io.mockk.gh.Issue70Test.test(Issue70Test.kt:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Minimal reproducible code (the gist of this issue)

package io.mockk.gh

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")
        }
    }

    @Test
    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

@oleksiyp

This comment has been minimized.

Collaborator

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.

@oleksiyp

This comment has been minimized.

Collaborator

oleksiyp commented May 6, 2018

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

@MrAlexSee

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