Conclusions
It takes time to become proficient in writing tests for legacy code and we understand that sometimes it is a daunting task. In this lesson, we distilled what in our opinion are the most important concepts on legacy code testing. Spending some time practicing the techniques we have outlined is an extremely useful exercise and we hope that it might give you some ideas helping to make that work a bit less daunting.
Guideline Questions
Is it important to understand the legacy code in detail?
If the answer is yes, characterization tests are probably the best solution. This is a slow process but gives us the best insight on how legacy code works.
Can we get by with a superficial understanding of the legacy code?
If the answer is yes and the system under test has clear inputs and outputs, we can probably use the Golden Master technique or Approval Tests.
We added a few web resources and books that go much deeper into this subject.