does anybody know if mockk v1.11.0 supports mockin...
# announcements
p
does anybody know if mockk v1.11.0 supports mocking inline value classes? it seems it does not…
c
try in #C9EJFT6DB . but i wonder how mocking inline classes should even work.
p
ok cool …
I think mockk will have to mock the inline value (e.g. an embedded string) instead
Copy code
@JvmInline value class CustomerName(val name: String)
should probably generate a mock that operates on String
e
Is there any value in mocking value classes? Have you added behaviour to it?
p
no, but I want to mock an interface call that returns a value class … and this does not seem to work
I got an answer on #C9EJFT6DB: https://github.com/mockk/mockk/issues/485
e
Ahh, that makes sense
p
this is the related issue
it’s currently unresolved
e
Not even this is possible?
Copy code
val mock = mockk<SomeInterface>()

every { mock.getCustomerName() } returns CustomerName("Some name")
p
based on my current experiments I would say: “no”
this narrows the usage of value classes in my case significantly
since testing is not optional
I get a error message like “CustomerName cannot be cast to java.lang.String”
I still do experiments and I will update
y
Could you try maybe doing a
returns
with the underlying datatype directly? E.g. every { mock.getCustomerName() } returns "Some name"