Problem here is that when the parameter passed to the method is wrong, you won't know what is wrong with it:
Too few invocations for: 1 * service.method({ it.firstname == "Peter" && it.surname == "Stawicki" }) (0 invocations) Unmatched invocations (ordered by similarity): 1 * service.method(eu.vegasoft.spocktest.validateparam.Person@40f892a4)Sometimes we want to validate also parameter passed to the mock method. We can do it like this:
Now when the passed parameter does not match, we can see exactly what was wrong with it:
Condition not satisfied: p.firstname == "Peter" | | | | Paweł false | 3 differences (40% similarity) | P(aw)e(ł) | P(et)e(r) eu.vegasoft.spocktest.validateparam.Person@34b23d12
No comments:
Post a Comment