|
|
|
|
|
by notaspecialist
1386 days ago
|
|
In all my years of coding, I only knew one developer who did TDD properly. He taught me, as I was struggling trying to track down an intermittent bug and nothing was working. Not going to lie -learning to do TDD properly is difficult. Since learning it, I've not met another dev who does it, and most devs barely write tests.
Stick with it, practice. You'll eventually hit that ahah! moment. A story: I used to work with some devs, most of them would finish coding something in 2 weeks and then spend a week debugging it. I'd take 4 weeks to TDD something. My boss was frustrated at my speed until one day a production system which I'd written, stopped working. Several million dollars was stuck in limbo, the backend team responsible for the paperwork unable to do anything. We had a new dev and the bandwagon was "TDD is crap!" was fully rolling that morning. I asked the backend processing person what had changed? The said we had a new client, they had a weird name. Looked into the client log, sure enough. Added a test with the client's name, and ran the tests. It spat out "1 failing test in module X at line Y because 'this'". Modified the code to handle that test, re-ran the tests, 100% pass. Emailed the results output to the team for a manual upload, processing done, committed and pushed to the production branch. The server would update after business hours. Diagnosed and fixed in 5 minutes.
I turned to my colleague who I knew was still stepping through his code for 2 days and said (within earshot of the new dev) "How's that bug you've been hunting? Still not found it? This is the power of TDD. I might be slow at the start, but I fix bugs quickly". The dev manager had everyone take a day of TDD training after that, but nobody really understood. The trainer said my approach to TDD is too strict, with my team doing 110 test runs against the next team of 63 test runs. Our solution had only a few lines of code verses the paragraphs of the others though. |
|
This is the material piece of information which lead to the fix. Your TDD simply made it faster to locate the offending line.
Seems like a really poor justification for TDD imo.