3 ms·
I think TDD is great in the ideal, but in reality I have only worked on legacy systems where TDD was not practiced from the start. Such systems are hard to fit
by mehagar 4y ago
I think TDD is great in the ideal, but in reality I have only worked on legacy systems where TDD was not practiced from the start. Such systems are hard to fit TDD style tests into because modifying existing code often requires large refactoring to properly inject dependencies and create seams for testing. The catch-22 is that refactoring itself is prone to breaking things without sufficient testing.
As a result, I often try to fit my tests into these existing systems rather than starting with the test and refactor the code under test to fit that shape. The only resource I've seen for dealing with this issue is the advice in the book "Working Effectively with Legacy Code", to write larger system tests first so you can safely refactor the code at a lower level. Still, that's a daunting amount of work when it's ultimately much easier for me to just make the change and move on.