Chapter 10. Mocking

Useful systems tend to have multiple behaviors. If a system only has one behavior, one could argue that test-driven development is not really necessary for that system.

Test-driven development is a means by which you document the behaviors that live in a system in tests. The trick is finding a way to test any one behavior separately from the others.

In classic object-oriented environments, the techniques for doing this are well established. In a nutshell, they all boil down to this: Hide dependency behaviors behind abstractions and then create implementations of those abstractions that have constant behavior. You can also use a rich host of tools to make such processes a lot easier.

My proposal is that the technique for mocking ...

Get Test-Driven Database Development: Unlocking Agility now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.