What’s the difference between using ```every {} re...
# mockk
v
What’s the difference between using
Copy code
every {} returns something
and
Copy code
every {} answers {something}
s
In the first example,
something
is evaluated only once and immediately. The 2nd example does not evaluate
something
immediately and will evaluate it later, each time when the mocked method is called.
👏 2
v
adding onto that, usually you give a lambda supplier to calculate the result to the
answers
clause where as
returns
takes an actual result
i
I thought
answers
was for the callbacks only
s
You can use
answers
to access the passed in parameters to respond with a specialized return value
l
You can also use answers to a more "complex" mock, that do more things
every {} answers { println("Mock!"); something }
700 Views