Código legado (frequentemente sem testes, difícil de modificar) é desafiador para testar — pode ter dependências emaranhadas e nenhum teste. Adicionar testes com segurança envolve técnicas como testes de caracterização, seams para quebrar dependências e melhoria incremental, possibilitando mudanças mais seguras.
O desafio do código legado
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.
