Tidying up Test Suites
Have you ever felt frustrated when working with your test suites? They can easily become messy and overgrown, unless you’re actively tending to them. In this chapter, we’ll look at some of the ways you can keep your test suites tidy.
The techniques you’ll use to tidy test suites differ from the techniques you’d use in your application code. Application code requires building abstractions and encapsulating details, with deep layers of connecting objects. However, tests benefit from being shallow, with each test statement having a clear effect.
Another way to think of it is that normal program flow can take many different paths through the code, but test suites have just one flow – they are scripts that run from top to bottom. There is an absence of control logic, such as conditional expressions and loop constructs.
The primary mechanism you have to control complexity in test suites is abstracting functions that hide...