3 ms·
> I fully subscribe to the definition of legacy code as “code without an automated test suite.” > I’ve never really subscribed to any of the test-driven-develo
by napo 10y ago
> I fully subscribe to the definition of legacy code as “code without an automated test suite.”
> I’ve never really subscribed to any of the test-driven-development manifestos or practices that I’ve encountered.
I feel the exact opposite. I've worked in project with a lot of legacy code, both with BDD or with UTs that we added latter on.
Even with the best intentions the latter always failed: we always ended up doing a lot of unreadable tests that had no meaning and that we were afraid to look at.
However, when I was working in a team fully committed on BDD, we were looking at the tests before looking at the code, the tests were in the center of the developing process, and we were able to write fast, solid, and simple tests.
Nowadays, I'm more interested on articles that understand that tests can be a pain too. And tbh I don't really trust articles that aim at a high coverage without talking about the different challenges that comes with tests.
- aisofteng 10y agoThis isn't exactly a fair comparison, in my opinion. Legacy code that was written before unit testing had become a habit tends to have a design that isn't always easily covered by unit tests; furthermore, when you give a team of engineers legacy code and ask them to add tests, they have to trace the source, make an interpretation of what they perceive the design considerations to have been, and then write tests to that. What you often end up with, though, is starting by unit testing the easier to understand pieces of code, checking for robustness to some bad inputs, and then somewhat skimping on unit tests on the code that most embodies the original authors' design considerations. Which, to be fair, is a highly nontrivial task that will realistically never be completed as well as if the original authors had written unit tests demonstrating the intent of their design. And the comparison you should have been making is to that scenario.