Published at last
Below is a post draft that I wrote in the summer of 2017 but for reasons I don't remember it has stayed as a draft since then.
Now, in the summer of 2023 I'll just add Martin Fowler's summary of the test doubles in the book "xUnit Test Patterns" copied from https://martinfowler.com/bliki/TestDouble.html (which I think is a great summary) and publish it.
The old draft
Do you know the differences between Fake, Stub and Mock when writing unit tests? I thought I did, and was about to write some kind of guide to use at work, but thought I'd do a little bit of research first to be sure to get the details correct. After reading on different pages I became more and more confused, until I found this page http://xunitpatterns.com/Test%20Double.html, that I think describes the types and their differences in a clear way that probably can be useful for us.
The page is on a webified version of the book xUnit Test Patterns: Refactoring Test Code that seem to be a great book that I have missed out on up until now.
When you know the differences between the types, then you might want to read more about how to choose between them according to Mark Seeman here: Mocks for Commands, Stubs for Queries
In his post Mocks Aren't Stubs, Martin Fowler also explains the difference between stubs and mocks and investigates pros and cons of the classicist and mockist way of writing your tests.
So, something that I thought I already knew and I could write about in an hour or so, ended in hours of research and a post with links... keeping it DRY :)