Fowler's example implemented in C++ using GoogleTest and GoogleMock can be found on GitHub.
Fowler provides an excellent discussion on the difference between classical test-driven development (TDD) and mockist TDD. As the title suggests, the argumentation is based on the difference between mocks and stubs:
While these definitions may be ambiguous for developers not familiar with the mockist approach to TDD, Fowler elaborates on the difference between state verification and behavior verification:
Only mocks, through expectations about function calls, insists on behavior verification. Stubs usually use state verification - as do all other kinds of test doubles, e.g. dummies or fakes. Overall, the difference between classical TDD and mockist TDD is made explicit through the following definitions:
The classical TDD style is to use real objects if possible and a double if it's awkward to use the real thing. So a classical TDDer would use a real warehouse and a double for the mail service. The kind of double doesn't really matter that much.
A mockist TDD practitioner, however, will always use a mock for any object with interesting behavior. In this case for both the warehouse and the mail service.
It remains the question which approach to use. To this end, Fowler discusses several advantages and disadvantages of mockist TDD compared to classical TDD. Advantages include:
The disadvantages include:
What is your opinion on the summarized work? Or do you know related work that is of interest? Let me know your thoughts in the comments below or get in touch with me: