Todo Add tests ...

· October 16, 2014

I added this line in a README file for one application I’m writing now. Like I have done before many times. However, for the longest time I have written my tests first, maybe not TDD or even unit tests, but I write the test first. Most of the times.

But not this time. Because I was in a hurry and I didn’t think that this application would be something we’d use.

And of course we ended up using it. And creates a financial record and prints a receipt. It’s kinda of important that it’s correct.

It just struck me:

  • how much harder it is to write the tests afterwards
  • how much I change in my production code, that wasn’t in place, when I go through it and test it
  • how much more boring it is to write the tests afterward
  • how easy and tempting it is to “cheat” and not test the hard stuff
  • how hard the feeling “this is not done/safe/correct/complete” hits me in the face
  • how little satisfaction I get from completing a test. It’s just like paying off an overdue bill. “Yes, I should have done this before. Now it’s done”.

I’m not saying that You have to write your tests first. I’m just saying that to me it’s: easier, safer, less boring, gives me better discipline and more rewarding. You do as you want.

I will never write “TODO: Add tests…” again without remember these feelings.

Twitter, Facebook