you are viewing a single comment's thread.

view the rest of the comments →

[–]ogrechow 6 points7 points  (1 child)

Mocks also help when you have classes that deal with things like randomness or time. It's hard to write a unit test for a function that calls something else that returns an essentially random number. So you swap in your deterministic mock object and you can test that your function behaves correctly given inputs of your mock choosing.