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 [27], 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 [34]. 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 so ...
Get Code That Fits in Your Head: Heuristics for Software Engineering 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.