Chapter 11. Editing Unit Tests
Few code bases are bootstrapped with the practices covered in the first part of the book. They have long methods, high degrees of complexity, poor encapsulation, and little automated test coverage. We call such code bases legacy code. There’s already a great book about Working Effectively with Legacy Code, so I don’t intend to repeat its lessons here.
11.1 Refactoring unit tests
If you have a trustworthy automated test suite, you can apply many of the lessons from Refactoring. That book discusses how to change the structure of existing code without changing its behaviour. Many of the techniques described in it are built into modern IDEs, such as renaming, extracting helper methods, moving code around, and ...