Let's say I want to test this function:
foo(input){
a = bar(input)
if(a)
return baz(0)
return baz(1)
}
(pseudocode)
I want to test foo
in isolation, so i mock bar
and baz
, but if I mock bar
the input becomes irrelevant. Unless the mocks care about their input, but then I'll mostly be testing my mockimplentation.
I also I don't want to test internals, but see that the correct input delivers the correct output. If I mock bar
, the output only relies on what I've told bar
to return in its mock implementations.