does springmockk allow to mock extension functions...
# spring
t
does springmockk allow to mock extension functions? (a bit of a stretch to ask here, as officially spring mockk is not associated with spring)
m
spring mockk work with mockk maybe this will helps https://mockk.io/#extension-functions
t
the thing is, in unit test (so plain
mockk
) it works, in spring test I see methods used in the extension function being called
it might be my project setup doing weird thing, and if I have time I will try to reproduce on a smaller scale, as apparently it is not a known limitations (I did not find related issues on springmockk github)
m
I think if try to mockStatic actually can be an option cos no matter what object your ext fun is targeting - you will get static fun wrapped in some class in bytecode e.g. in groovy my ext fun call (God will forgive 😃 ) looks like
Copy code
PartModelKt.toDto(partRepository.save(partForRepository), [], [], [], [], [])
kotlin equivalent
Copy code
partRepository.save(partForRepository).toDto(/*optional args*/)
or in your case PartModelKt - is a bean object?
t
yes, it is a bean. I guess I can try
mockkStatic
, that should mockk the universe if I got it correctly, no matter the actual implementation
so, I found out I misunderstood the documentation, and I should have used
mockkStatic
, because I defined my extension function as module wide.