A conversation with Robert Martin (Uncle Bob) about "Test Doubles"
We can say that a Mock is a kind of spy, a spy is a kind of stub, and a stub is a kind of dummy. But a fake isn't a kind of any of them. It's a completely different kind of test double.
Since DHH's opening keynote at Railsconf 2014 in which he questioned the use and value of TDD, and his subsequent post titled "TDD is Dead, Long Live Testing" have generated a lot of reaction and controversy. Much of the reaction has been focused on how TDD is, or should be, applied and used.
…
Much of the response has focused on the need to apply TDD pragmatically.
Uncle Bob Martin says in a response that “If you aren't doing TDD, or something as effective as TDD, then you should feel bad.” He continues
Why do we do TDD? We do TDD for one overriding reason and several less important reasons. The less important reasons are:
1. We spend less time debugging.
2. The tests act as accurate, precise, and unambiguous documentation at the lowest level of the system.
3. Writing tests first requires decoupling that other testing strategies do not; and we believe 0 that such decoupling is beneficial.
Those are ancillary benefits of TDD; and they are debatable. There is, however, one benefit that, given certain conditions are met, cannot be debated:
• If you have a test suite that you trust so much that you are willing to deploy the system based solely on those tests passing; and if that test suite can be executed in seconds, or minutes, then you can quickly and easily clean the code without fear.