Some say “mocks suck”, because they reduce a test’s realism and with it the confidence that the code being tested actually works. Others use mocks to demarcate the outer boundary of an application, guarding the test from expensive or external dependencies (e.g. by faking a database or network resource). Still others see mocks as a “setup of last resort”, using them only to mitigate the pain of hard-to-test code. Finally, some developers mock out every collaborator in every test, and their rationale is probably the least understood of them all!
This talk will serve as an opinionated (if broad-stroke) survey of the different ways people use test doubles (be they mocks, fakes, stubs, or spies). Our goal will be to establish a more sophisticated means of communicating on the topic. We’ll discuss the pros and cons of the different approaches toward mocking, the smells of test double abuse, and the lessons I took away from writing my own test double library.
Watch this video on Oredev.org