Refactored Telegram

It’s all just ones and zeros under the cover

A Case For Mocking in Unit Tests

Here’s a short account of a realisation I had this morning on the occasional usefulness of mocks in unit tests. I’ve never been a huge fan of mocking in unit tests. The code to set them up is tedious to write, and tends to be very fragile. Any change or refactor you make to the module being tested — even if the behaviour doesn’t change — and all your tests break because the mocks are no longer called the way they were. This goes against one of the key principals of unit testing in my opinion, in that it is the behaviour of the module is being verified, not the actual implementation.

However, today I came across a case where a mock would have come in handy.

Read more →