
577
Other Naming Considerations
People might ask why I sometimes propose alternative names for some
patterns. The preceding story highlights one of the reasons. Another
reason is that in a larger collection of patterns (such as this book), it is
important that there exists a “system of names.”
Let me illustrate this second reason with an example. Many people
advocate the use of a setUp method to create the test fi xture. This approach
moves the fi xture setup logic out of each individual Test Method (page 348)
and into a single place where it can be reused. Many people might refer to
this pattern as “Shared Setup Method.” But in this pattern language, I’ve
chosen to call it Implicit Setup (page 424). Why?
It comes down to the names of other patterns in the language. On the one
hand, “Shared Setup Method” could easily be confused with the existing
pattern Shared Fixture (page 317). (The former pattern deals with sharing
code, whereas the latter pattern focuses on sharing the runtime objects
in the fi xture.) On the other hand, the two major alternatives to Implicit
Setup are called In-line Setup (page 408) and Delegated Setup (page 411).
Wouldn’t you agree that “In-line Setup, Delegated Setup, Implicit Setup”
forms a better “system of names” than “In-line Setup, Delegated Setup,
Shared Setup Method”? The connection between the pattern names is
much more obvious when we consider all the major alternative patterns
when choosing the system of names.
Why Standardize Testing Patterns?
The last part of this soapbox highlights why I think it is important for us
to standardize the names of the test automation patterns, especially those
related to Test Stubs (page 529) and Mock Objects (page 544). The key
issue here relates to succinctness of communication.
When someone tells you, “Put a mock in it” (pun intended!), what advice
is that person giving you? Depending on what the person means by a
“mock,” he or she could be suggesting that you control the indirect inputs
of your SUT using a Test Stub or that you replace your database with a
Fake Database (see Fake Object on page 551) that will reduce test inter-
actions and speed up your tests by a factor of 50. (Yes, 50! See the sidebar
“Faster Tests Without Shared Fixtures” on page 319.) Or perhaps the
person is suggesting that you verify that your SUT calls the correct meth-
ods by installing an Eager Mock Object (see Mock Object) preconfi gured
Continued...
Hard-Coded Test Double
Hard-Coded
Test Double