Step 4: Remove Duplication in the Test

Scanning the tests, we can see instantly that this is another classic case of copy and paste. No need to pass judgement here. We don’t know the kind of pressure the author was under when they wrote this. At least we have tests!

Going through a similar exercise with the tests, let’s start by circling all the places we see duplication, and then thinking of some options for dealing with it after.

images/programming/hammer4.png

Here’s some stuff that immediately jumps out.

images/programming/hammer5.png

The header and footer variables are redeclared in each test—no need for ...

Get The Way of the Web Tester 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.