Mocks, Fakes, Stubs and Dummies

Are you confused about what someone means when they say "test stub" or "mock
object"? Do you sometimes feel that the person you are talking to is using a very
different definition? Well, you are not alone!

The terminology around the various kinds of Test Doubles (page X) is
confusing and inconsistent. Different authors use different terms to mean the same
thing. And sometimes they mean different things by the same term! Ouch! (See
the sidebar What's in a (Pattern) Name? (page X) for why I think names are important.)

Part of the reason for writing this book was to try to establish some
consistency in the terminology to give people a set of names with clear definitions
of what they mean. In this sidebar, I provide a list of the current sources and
cross-reference the terminology they use with what I use in this book.

Role Descriptions

Here is a summary of what I mean by each of the major Test Double pattern names:

Unit Testing With Java ([UTwJ]) uses the term "Dummy Object"
to refer to what I am calling a "Fake Object".

Pragmatic Unit Testing [PUT] describes a "Stub" as an empty
implementation of a method. This is a common interpretation in the procedural
world but in the object world this is typically called a Null Object[PLOPD3].

Some of the early Mock Objects literature could be interpreted to equate
a Stub with a Mock Object. This has since been clarified in [MRNO] and [MAS].

The CORBA standard (CORBA stands for Common Object Request
Broker Architecture and is defined by the Object Management
Group)and other remote-procedure call specifications use the terms
"stubs" and "skeletons" to refer to the automatically generated code for the
near and far end implementation of a remote interface defined in IDL. (I've
only included this here because it is another use of one of the terms we
commonly use in the TDD and automated developer testing community.)