You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we tries to mock the get method in the selected interface:
interfaceA<K, V> {
funget(k:K): V?
}
like this
val a = mockk<A<Any, ByteArray>>()
every { a.get(any()) } returns byteArrayOf()
the test will be crashed with an exception.
Steps to Reproduce
Create the interface
interfaceA<K, V> {
funget(k:K): V?
}
Run selected in a test case
val a = mockk<A<Any, ByteArray>>()
every { a.get(any()) } returns byteArrayOf()
Context
MockK version: 1.8.13.kotlin13
OS: Win10
Kotlin version: 1.3.30
JDK version: 1.8.0_144
JUnit version: JUnit 4.12
Type of test: android instrumented test
Also using androidx artifacts
Stack trace
Just a stack trace directly from my app
java.lang.ClassNotFoundException: Invalid name: byte[]
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at io.mockk.impl.recording.JvmAutoHinter.autoHint(JvmAutoHinter.kt:38)
at io.mockk.impl.eval.RecordedBlockEvaluator.record(RecordedBlockEvaluator.kt:36)
at io.mockk.impl.eval.EveryBlockEvaluator.every(EveryBlockEvaluator.kt:25)
at io.mockk.MockKDsl.internalEvery(API.kt:93)
at io.mockk.MockKKt.every(MockK.kt:104)
at com.makentoshe.booruchan.common.download.PreviewImageDownloadControllerATest.shouldReturnSuccessForFirst(PreviewImageDownloadControllerATest.kt:36)
at java.lang.reflect.Method.invoke(Native Method)
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 androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
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.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
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 org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:388)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2089)
Minimal reproducible code (the gist of this issue)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you are sure that this issue is important and should not be marked as stale just put an important tag.
oleksiyp
changed the title
Bug: Interface with 2 generics mock (Invalid name: byte[])
Bug: ClassCastException(Invalid name: byte[]) in generic interface mocking
Nov 2, 2019
Expected Behavior
Mocked method should returns ByteArray
Current Behavior
If we tries to mock the
get
method in the selected interface:like this
the test will be crashed with an exception.
Steps to Reproduce
Context
Also using androidx artifacts
Stack trace
Just a stack trace directly from my app
Minimal reproducible code (the gist of this issue)
The text was updated successfully, but these errors were encountered: