I have started working my way through the book Working Effectively with Legacy Code. I have been recommended this book multiple times and purchased it a while ago but hadn’t gotten around to reading at. A few take-aways I got from the first few chapters:
What is a unit test?
According to the author a unit test isn’t a ‘unit’ if:
- It talks to a database
- Makes network calls
- Touches the file system
- Relies on a special environment configuration/setup
Rules for changing legacy code
The author identifies the following steps to making changes.
- Identify change parts
- Find the test points
- Break the dependencies.
- Write tests for this code
- Make changes and refactor