Hey I’m having issues mocking an extension propert...
# mockk
a
Hey I’m having issues mocking an extension property, how can one do it? Suppose I have
class MyService { … }
and an extension property like
Copy code
val MyService.myProp: String
    get() = "value"
when doing
Copy code
mockk<MyService> {
    every { myProp } returns "otherValue"
}
it throws a
MockkException
msg:
Missing mocked calls inside every { ... } block: make sure the object inside the block is a mock
It is mentioned here that I can do
mockkStatic(MyService::myPro)
although I cannot create a KProperty of an extension prop
myProp is a member and an extension at the same time. References to such elements are not allowed
Oh it needs to be in global scope
👍 1
If it is a member I need to mock the class where it is defined right?
1043 Views