Mock Objects Defined

One complicating factor in dealing with test doubles is that pretty much everybody who creates a tool feels perfectly free to use slightly different naming conventions than everybody else. Here are the names that I use, which are—of course—also the correct ones. (Actually, I believe this naming structure is the creation of Gerard Meszaros in xUnit Test Patterns [Mes07].)

The generic term for any object used as a stand-in for another object is test double, by analogy to “stunt double” and with the same connotation of a cheaper or more focused replacement for a more expensive real object. Colloquially, “mock object” is also sometimes used as a generic term but, confusingly, is also the name of a specific type ...

Get Rails 4 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.