Remember the first time you introduced a new feature or made a new fix and wrote the tests first? That felt good, right? Liberating? Empowering?
“I’m the master of the universe!” - you said to yourself, hopefully in your head.
Well today I just felt the flip side of that particular coin. Today I made a fix to some legacy code, without writing any tests at all. Most of the testing was manual and, while it was thorough, the entire process was incredibly slow and painful compare to the usual whizz of the automated tests flying by.
If ever you feel tempted to go back to code-first development, try it the next time you’re staring an impossible deadline in the face and see if it’s really faster.
Incidentally, I actually found a new bug in the legacy code that had gone unnoticed for some time, due to watching the automated parts of the tests run so I could manually test my fix.
A healthy test approach could be a bit like a balanced diet; eat fats and sugars in moderation and do some exercise. In your tests, use automation in moderation (not for its own sake) and practice your testing, to stay sharp.
Beware the green bar!