https://kotlinlang.org logo
#mockk
Title
p

Patrick Ramsey

09/03/2021, 12:05 AM
I think the answer is probably “no”, but is there any way to mock @JvmStatic fields on a singleton object using mockk? mockkObject() doesn’t seem to do the trick (
every { Singleton.field }
breaks because there’s no accessor to mock) and mockkStatic(Singleton::class) doesn’t seem to work either (
every { Singleton.field }
doesn’t result in an exception, but accessing Singleton.field still returns its original value)
2 Views