Test Doubles 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 I use, which are—of course—also the correct ones. (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 specialized 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 of test double.

A fake is typically ...

Get Rails 5 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.