In my experience its a lot of effort for not much return. On top of the tests themselves you have to often code things in an awkward way to avoid having to mock everything out, or worse you have to mock everything out, or worse avoid otherwise useful patterns.
And for that you get what? 95% of the time they only catch an issue with the unit test itself and not an actual bug impacting the actual system. And then faced with evidence that the whole endeavour is a giant waste of time someone will sigh and say, if only we were implementing TDD correctly and try to use this failure of TDD as a reason to further indoctrinate impressionable junior devs on the importance of wasting their days on shitty unit tests that dont actually test anything.
Automated functional testing and full end to end testing are useful. TDD is just something dumb that people got scammed by.
TDD works if it's something that you're not adhering to a real deadline. Plus you-or at least one person on the project-already know how to build it completely and how it should work.
It can also show you real quick which of your co-workers is terrible at procedural programming despite the test being open book and take as long as they need.
I find Test Driven Development to be great if you are addressing a real production issue and can reasonably recreate the failure scenario in your tests.
That also helps prevent this specific issue from cropping back up again, if you're able to write a test with a comment that says something like "Adding this test to verify we fixed the bug that caused Ticket # 1234."
Admittedly I've only been in the industry about 5 years now, but I've only used TDD on 1 service out of the ~50 microservices I've worked on.
It was a data query and calculation engine so we knew exactly what number should come out based on its input. Anything behaviour driven is much hard to write a unit test beforehand.
I find Test Driven Development to be great if you are addressing a real production issue and can reasonably recreate the failure scenario in your tests.
Is that TDD? The TDD people have the AI doing is writing tests before the very first line of code, and to implement new features, not merely fixing bugs on an existing product with users.
They do share methods and some of the associated benefits obviously, but what you describe sounds like just writing non-regression tests to me, not Test Driven Development.
TDD is writing tests you know will fail, then writing/refactoring code that will pass said tests, then going back to write more tests for more features
Compiler errors are a form of TDD, like TypeErrors and Syntax errors
Everyone uses TDD in some form... most are just using the IDE to do it for them
AI uses TDD because it's the only way for it to know if something works or not. One shotting isn't anywhere near as good as folks might claim without TDD. The agent will write a test, write code, then run the test, realize the test fails, and try to treat that as a new debugging session. End user only sees the final result with passing tests. In other words, AI's tests aren't there for future use, they're a mechanism to mock up what devs themselves do (create a small part of a project, run it a few times until they're happy, then move onto the next).
It's the best application of TDD. To prevent regressions. Outside of that TDD is pretty lousy, especially when you have Type Driven Development and are trying to figure out an elegant way of solving a problem. You might not know how the final API and code is going to look like ahead of time. And the "makes your code easily testable" is still easy to do when you define types and think in terms of functions and inputs/outputs.
I should have clarified that I also don't use TDD for new features, just fixing regressions. And as long as you write the test before fixing the bug in code, that counts as TDD!
TDD only works if you get fully defined stories with complete AC. And such stories are considered mythological as there are no verified reports of one being seen.
Even then, the fully defined stories are not going to tell you how to structure the API or the folder structure or what inputs and outputs are going to help you write the code internally.
What even IS test driven development, I literally don't understand it. Do you simply write all the tests first and write the code around it? How do you know what functions you are gonna test if you didn't write them yet? What if during coding you figure out a better way to write a bit of code that involves using 3 subroutines? You didn't write the tests for those so are they invalid? Do you go back to the tests and change them? Is that still test driven development? Do you have know in advanced that you are going making a discrete function that extracts some json data?
View all comments
Show parent comment
0
u/[deleted] Oct 20 '26
[deleted] — view deleted comment