Kod legacy (często nietestowany, trudny do modyfikacji kod) jest trudny do testowania — może mieć splątane zależności i brak testów. Dodawanie testów bezpiecznie obejmuje techniki takie jak testy charakteryzacyjne, seamy do przerwania zależności i inkrementalne ulepszanie, umożliwiające bezpieczniejsze zmiany.
Problem kodu legacy
Legacy code is often: untested, tightly coupled, hard to understand, risky to change:
→ no tests → changing it is dangerous (you can't tell if you broke something)
→ hard to test → dependencies are tangled (can't isolate units); not designed for testing
→ a chicken-and-egg problem: to change safely you need tests, but it's hard to test.
