Hi, Is there a difference between `mockk<T>...
# mockk
r
Hi, Is there a difference between
mockk<T>(relaxed = true)
vs.
spyk
? I tend to think of them as the same and use the former is useful for when there is a default constructor and the the latter if I need to pass properties to a constructor, and otherwise think they end up the same…. but maybe I am wrong?
m
yes there is a slight difference: when you invoke a method on a spy, if it has not been stubbed, the actual method on the object will be invoked. if you do the same thing on a relaxed mock, the actual method will not be invoked and it will return a default answer, e.g. an empty list if the method returns a List
t
usually you use mocks to configure a behavior, spies to observe
👍 1
mattia ninjad me 😄
🥷 1
r
ah, that is a very subtle and interesting difference thanks @Mattia Tommasone
m
@thanksforallthefish’s point is definitely valid though