Chapter 31. Test Setup

“It’s not what I do, but the way I do it. It’s not what I say, but the way I say it.”

Mae West

This chapter discusses the trade-offs between using an individual setup for tests and using a common setup. It also explores concerns about test order and persistent storage.

A Common Setup

You may have noticed that the setup for several of the triad’s tests started to be repetitious. All the tests need customers and CDs to rent or return. It is tempting to place the repetitive setup into a common setup. There is a classic trade-off between decreasing duplication by the common setup and increasing the possibility that altering the common setup causes failing tests.1 A common setup for all tests might be as follows.

Get Lean-Agile Acceptance Test-Driven Development: Better Software Through Collaboration now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.