Chapter 10. Advanced testing techniques
This chapter covers:
Once, as I was zapping TV channels, I happened upon an unfamiliar soap opera. A man was saying to a woman, “We’re real people; we have real feelings.” If I had been following the program from the start, I would probably have been mildly amused by this. But coming in suddenly, it struck me how extraordinary a statement this was, a fictional character bombastically proclaiming himself real.
Working with software, we’re used to juggling the real and the unreal. In computing, it’s a matter of taste whether you consider anything real or not, other than hardware and moving electrons. Ultimately, it’s mostly fake. The kind of fiction in which dreams and reality mingle in complex ways (like The Matrix) seems like a natural thing to us.
But the idea that some software objects are “fakes,” in contrast to normal objects, is important in testing. Most fake objects are referred to as mock objects. Their fakeness does not imply that ordinary objects are as real as chairs or giraffes. Instead, the fakeness of mock objects is determined by the fact that they work only in the context of testing and not in an ordinary program.