When you think about it, the process of adding new behavior to a system isn’t so different from fixing a bug. The overall goal is to change some aspect of how the system behaves, without breaking anything else.
Just as with bug fixing, we can use characterization tests to pin down the surrounding behavior of the system to be sure it isn’t dislodged by our work. Characterization tests can also be useful before that, while the new feature is first being considered. You can use them to understand how much work is involved in the new feature by clarifying exactly what the system currently does.
Here’s our recipe for adding new behavior to a legacy system:
Examine the new feature. If necessary, write a few characterization ...