Maybe because it's not cheaper, or easier. I've been coding for a long time and we never had unit testing tooling or TDD or stuff like that, and our code worked. Three internet is built on it, and nobody did TDD with the internet stacks, they thought-out what was needed, and then did it (and sure, fixed bugs along the way as even code written using TDD practices do).
Unit testing came along as fashionable and caused use to write our code differently, test tiny sections, and still we ended up having to perform old fashioned integration tests, and I think many people saw this effort, tried it, and because it didn't really save much time in the whole, and because integration and systems test still had to be done, got a bit bored and disillusioned with it. After all, you can test a system with integration tests and no unit tests. You cannot do the opposite!
In my experience to really get code tested properly you need to split the roles, Devs should dev and testers should test, partly because they can do it well with the tools they learn but also because testing your own code can be problematic, you tend to think of it in terms of it working (obviously) whereas a tester will think of it not working. That attitude makes a big difference.
One place I worked, myself and another dev tested each others code and our productivity and accuracy increased.
So TDD, I think is more specialised, a way of coding that only appeals to a relative few people. That's probably why it has never really taken off in industry.
Thanks for this comment. I agree that people have different motivations and that TDD appeals to only a small proportion of people. Plus, there's often no incentive for devs to test--their performance isn’t linked to it, especially when companies have specialised test teams. Which all tallies with what you’re saying. What I disagree with is that testing can’t save time/money—while that’s certainly true for a lot of people, for many contractors/consultants testing becomes the reason why they are so highly valued in the community, because they can build maintainable, high-quality software that is built to last.
However I think the problem lies with the TDD/testing community on this one. We need to innovate. To find ways that everyone can be successful with testing and incentivize it enough that all devs want to do it, not just the ones that enjoy writing testable code.
Unit testing doesnt take the place of integration and e2e testing. Used together they become whole and eliminate the need for testers. It is the developers responsibility to check for failures through different tests in my company.
If you skip on unit tests, tests will run slower and be more brittle for the same test coverage
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.