Test smells

In the previous sections, we discussed some best practices for writing good test code. Now let’s discuss test smells. The term code smell indicates symptoms that may indicate deeper problems in the system’s source code. Some well-known examples are Long MethodLong Class, and God Class. Several research papers show that code smells hinder the comprehensibility and maintainability of software systems (such as the work by Khomh and colleagues [2009]).

While the term has long been applied to production code, our community has been developing catalogs of smells that are specific to test code. Research has also shown that test smells are prevalent in real life and, unsurprisingly, often hurt the maintenance and comprehensibility of the test suite (Spadini et al., 2020).

The following sections examine several well-known test smells. A more comprehensive list can be found in xUnit Test Patterns by Meszaros (2007). I also recommend reading the foundational paper on test smells by Deursen and colleagues (2001).


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *