← Back to context

Comment by aleksiy123

12 days ago

If the normal way of testing is passing some parameters to test some code is what I'm going to call "outside-in" testing.

Then mocking is "inside-out" testing. You check that your code is passing the right params/request to some dependency and reacting correctly to the output/response.

Its really the same thing and you can flip between them by "inverting".

Sometimes mocking just makes much more sense, and sometimes just passing paramaters to a function directly does. The end goal is the same: test some unit of codes behaviour against some specific state/situation.

They have their place but like all testing should be layered with other types of test to "test in depth".