Hello, how do I effectively mockk a value class?
# mockk
m
Hello, how do I effectively mockk a value class?
if I mockk a value class, I get
Copy code
io.mockk.MockKException: no answer found for: MyClass(#8).unbox-impl()
If I remove the whole value class aspect, my tests run and work
e
you can't (and like data classes, I don't think it generally makes sense to)
👍 2
m
follow up problem:
Copy code
sealed interface Sealed{
    @JvmInline value class MyClass(someOtherClassINeedToMockk: Any) : Sealed
}
gives me the following error:
Copy code
cannot cast 'the class I want to mockk' to 'Sealed'
when my code checks:
Copy code
val isTheClassIneed = sealed is MyClass
only in the mockk when the class is a value class
e
any type of upcast loses the value-ness of a value class so I'm not sure what you're trying to do there
256 Views