DEV Community


Discussion on: TDD success/horror stories? #discuss 🙀

jamesmcmahon profile image
James McMahon Author

Oh yeah, I can completely see that. It is so hard to retrofit unit tests into code not written with testability in mind.

I don't know if you are familiar with the book Working Effectively with Legacy Code but one of the recommendations they layout is to a high level / black-box approach when it comes to testing legacy code.

How did that project turn out, did they persevere until they had high code coverage?

jacklowrie profile image
Jack Lowrie

The project has turned out well so far, and they are still persevering! We're continuing to get work from them in 'buckets of hours' contracts, augmenting their in-house team, though I think it will be a while before they achieve their desired level of code coverage.

I love that idea of treating legacy code as a black box, and will definitely need to read that book. Since the project may have left a sour taste in the mouths of coworkers whose first exposure to unit tests was on this project (and experienced the nuisance of failing pipelines due to missing tests), that black box approach might bring them back around. Thanks for the recommendation!