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
Please answer the following questions for yourself before submitting an issue.
I am running the latest version
I checked the documentation and found no answer
I checked to make sure that this issue has not already been filed
Expected Behavior
getProperty is work with private field of parent class.
Current Behavior
Can't find property signature in mock class(child class).
Failure Information (for bugs)
Bug 1 (Normal case, property is not accessable in child) InternalPlatformDsl#dymaicGet in JVM find only Mock Class. dymaicGet need to find there parent class.
io.mockk.MockKException: can't find property privateProperty for dynamic property get
Stack trace
// -----------------------[ YOUR STACK STARTS HERE ] -----------------------
can't find property privateProperty for dynamic property get
io.mockk.MockKException: can't find property privateProperty for dynamic property get
at app//io.mockk.InternalPlatformDsl.dynamicGet(InternalPlatformDsl.kt:164)
at app//io.mockk.MockKMatcherScope.getProperty(API.kt:2065)
at app//io.mockk.it.PrivateParentPropertyTest$testPrivatePropertyMock$1.invoke(PrivateParentPropertyTest.kt:45)
at app//io.mockk.it.PrivateParentPropertyTest$testPrivatePropertyMock$1.invoke(PrivateParentPropertyTest.kt:45)
at app//io.mockk.impl.eval.RecordedBlockEvaluator$record$block$1.invoke(RecordedBlockEvaluator.kt:25)
at app//io.mockk.impl.eval.RecordedBlockEvaluator$enhanceWithRethrow$1.invoke(RecordedBlockEvaluator.kt:78)
at app//io.mockk.impl.recording.JvmAutoHinter.autoHint(JvmAutoHinter.kt:23)
at app//io.mockk.impl.eval.RecordedBlockEvaluator.record(RecordedBlockEvaluator.kt:40)
at app//io.mockk.impl.eval.EveryBlockEvaluator.every(EveryBlockEvaluator.kt:30)
at app//io.mockk.MockKDsl.internalEvery(API.kt:94)
at app//io.mockk.MockKKt.every(MockK.kt:143)
at app//io.mockk.it.PrivateParentPropertyTest.testPrivatePropertyMock(PrivateParentPropertyTest.kt:45)
at java.base@11.0.16/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base@11.0.16/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base@11.0.16/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base@11.0.16/java.lang.reflect.Method.invoke(Method.java:566)
at app//org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
at app//org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
...
// -----------------------[ YOUR STACK TRACE ENDS HERE ] -----------------------
Minimal reproducible code (the gist of this issue)
I would like to have this feature too. I'm struggling with this for a while now. 😢
@ShinJJang I think your solution will work, try to change your private property to a lazy {} property and have it a go. There's another issue with mocking private instances when they are statically initialized: #263
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Expected Behavior
getProperty
is work with private field of parent class.Current Behavior
Can't find property signature in mock class(child class).
Failure Information (for bugs)
Bug 1 (Normal case, property is not accessable in child)
InternalPlatformDsl#dymaicGet
in JVM find only Mock Class.dymaicGet
need to find there parent class.For reference above issue, I try to apply
allAncestorProperties
todymaicGet
, but occur below error.I have could not resolve this.
Bug 2 (Shadowed property of private property in parent class as default accessor)
I don't know what is root cause and this is related with
Bug 1
Context
Failure Logs
io.mockk.MockKException: can't find property privateProperty for dynamic property get
Stack trace
Minimal reproducible code (the gist of this issue)
The text was updated successfully, but these errors were encountered: