I'm trying to mock private properties from in a co...
# mockk
m
I'm trying to mock private properties from in a companion object. When I run the tests they throw an exception.
io.mockk.MockKException: can't find property workerHandler for dynamic property get
m
I think it may be an issue with the fact that the first argument for mockkObject is vararg, so if you call it the way you do the second parameter is part of the vararg
it should be working if you write it as
mockkObject(GeoJsonSource.Companion, recordPrivateCalls = true)
m
When I switch to that I get
Missing mocked calls inside every { ... } block: make sure the object inside the block is a mock
which is what I got before adding the
true
argument.
So it is the mocking of the
mainHandler
that fails, The
workerHandler
passes. Looking at the decompiled code, the
mainHandler
is turned into a static field of the
GeoJsonSource
class and there is no getter in the
Companion
object.
573 Views