by taylodl · 3y ago · 0 comments
Seriously. TDD does not, nor ever has, said anything about the quality of the design. It merely says it will be testable. While a design that is testable may not be "the best" design (presuming some agreed-upon ordering of goodness of design, which there isn't), it is at least testable and can be proven to work as intended.
That, in the end is what this is all about. Do you go with what people feel is the best design but you can't prove the result, or do you go with what people feel is the poorer design but you can test the result and prove it works?
Make this decision as though your life and/or life savings depended on it.
However, I don't think TDD even ensures testability, especially in javascript/node and similar languages. You can always use goofball mocking frameworks, reflection, and monkey patching to brute force a test into working. That's what I wrote this blog post about.
I see real wonky tests a lot, and am confronted by test automation skeptics with bad past experiences, and so I wrote the blog post really for that audience and also for the people who _DO_ claim TDD forces a high quality design.
There are approaches to provide much stronger assurances, both on the testing and implementation sides, but they’re typically outside the scope of pure play TDD.
And I’ll take a decent assurance over the lack of one any day of the week.
I think where TDD may not work well is with legacy systems where people try to bolt on tests after the fact.
I get the impression from the article that this might be the case.
He takes a strong "test first" approach and talks about all the work you have to do when working on a system that isn't testable to change it safely with TDD.