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
android project, having some unit test working fine until updated to java 17.
Here is a simplified test to show that the spyk(HashMap()) gets error
@Test
fun test_() {
val metaMapSpy: MutableMap<String, String> = spyk(HashMap())
every { metaMapSpy[any()] } returns null
val ret = metaMapSpy["mLS"];
assertEquals("should return null", null, ret)
}
using
mockk 1.13.5
robolectric 4.10.2
java 17
class io.mockk.impl.InternalPlatform cannot access a member of class java.util.HashMap (in module java.base) with modifiers "transient"
java.lang.IllegalAccessException: class io.mockk.impl.InternalPlatform cannot access a member of class java.util.HashMap (in module java.base) with modifiers "transient"
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
at java.base/java.lang.reflect.Field.checkAccess(Field.java:1102)
at java.base/java.lang.reflect.Field.get(Field.java:423)
at io.mockk.impl.InternalPlatform.copyFields$copy(InternalPlatform.kt:114)
at io.mockk.impl.InternalPlatform.copyFields(InternalPlatform.kt:121)
at io.mockk.impl.instantiation.AbstractMockFactory.spyk(AbstractMockFactory.kt:107)
with java 17, how to use mockk.spyK to mock a map?
The text was updated successfully, but these errors were encountered:
android project, having some unit test working fine until updated to java 17.
Here is a simplified test to show that the
spyk(HashMap())
gets errorwith java 17, how to use mockk.spyK to mock a map?
The text was updated successfully, but these errors were encountered: