Chapter 15Code Smells

Smells in This Chapter

      Obscure Test 186

      Conditional Test Logic 200

      Hard-to-Test Code 209

      Test Code Duplication 213

      Test Logic in Production 217

Obscure Test

Also known as

Long Test, Complex Test, Verbose Test

It is difficult to understand the test at a glance.

Automated tests should serve at least two purposes. First, they should act as documentation of how the system under test (SUT) should behave; we call this Tests as Documentation (see page 23). Second, they should be a self-verifying executable specification. These two goals are often contradictory because the level of detail needed for tests to be executable may make the test so verbose as to be difficult to understand.

Symptoms

We are ...

Get xUnit Test Patterns: Refactoring Test Code 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.