
10
What’s a Test Smell?
A smell is a symptom of a problem. A smell doesn’t necessarily tell us what is 
wrong, because a particular smell may originate from any of several sources. 
Most of the smells in this book have several different named causes; some causes 
even appear under several smells. That’s because a root cause may reveal itself 
through several different symptoms (i.e., smells). 
Not all problems are considered smells, and some problems may even be the 
root cause of several smells. The “Occam’s razor” test for deciding whether 
something really is a smell (versus just a problem) is the “sniffability test.” That 
is, the smell must grab us by the nose and say, “Something is wrong here.” As 
discussed in the next section, I have classifi ed the smells based on the kinds of 
symptoms they exhibit (how they “grab us by the nose”). 
Based on the “sniffability” criteria, I have demoted some of the test smells 
listed in prior papers and articles to “cause” status. I have mostly left their 
names unchanged so that we can still refer to them when talking about a par-
ticular side effect of applying a pattern. In this case, it is more appropriate to 
refer directly to the cause rather than to the more general but sniffable smell. 
Kinds of Test Smells 
Over the years we have discovered that there are at least two different kinds of 
smells: code smells, which must be recognized when looking at code, and behav-
ior smells, which affect the outcome of tests as they execute. 
Code smells are coding-level anti-patterns that a developer, tester, or coach 
may notice while reading or writing test code. That is, the code just doesn’t look 
quite right or doesn’t communicate its intent very clearly. Code smells must fi rst 
be recognized before we can take any action, and the need for action may not be 
equally obvious to everyone. Code smells apply to all kinds of tests, including both 
Scripted Tests (page 285) and Recorded Tests (page 278). They become particu-
larly relevant for Recorded Tests when we must maintain the recorded code. Un-
fortunately, most Recorded Tests suffer from Obscure Tests (page 186), because 
they are recorded by a tool that doesn’t know what is relevant to the human reader. 
Behavior smells, by contrast, are much more diffi cult to ignore because they 
cause tests to fail (or not compile at all) at the most inopportune times, such as 
when we are trying to integrate our code into a crucial build; we are forced to 
unearth the problems before we can “make the bar green.” Like code smells, 
behavior smells are relevant to both Scripted Tests and Recorded Tests.
Chapter 2  Test Smells