Subscribe via RSS

Don’t Unit Test? Start Counting Your “Oh Shits!”

Filed Under Software Process

Finger Counting

I have heard every excuse of why not to unit test. The most common excuse is “it takes too much of my time”. I can sympathize, but I give you one simple challenge – start counting your “Oh Shit” moments.

There are many moments you can start counting.

Oh Shit I …

  • didn’t code that right (the very first time)
  • just broke previously working functionality
  • fixed a bug, but created another bug (or two)

How many “Oh Shit” moments would you have in a day? In a week? On a project? They can really add up. Most importantly, you can measure how much time you spent fixing things you didn’t need to.

Obviously you can also measure time spent building unit tests, but the time saved not spent on “Oh Shit” moments now becomes transparent and immeasurable.

Simple challenge – count the number of times you think “Oh Shit”. Hopefully, this small act will give you a more aware perspective of wasted time and the time investment of unit testing.

RSS Icon

  Don't miss a drop! Subscribe now via RSS or email.


10 Responses to “Don’t Unit Test? Start Counting Your “Oh Shits!””

  1. Neil Barnwell on November 14th, 2007 5:31 am

    Of course the really hard bit is starting to add unit tests to that huge application you already have, that’s not written with unit testing in mind. You start to need to count the “Oh shit, I could’ve avoided this with a unit test” separate from “Oh shit, if only this system didn’t need re-writing to be able to unit test it.”.

    I think there is a separate group of people in addition to the “unit tests are part of my day” and “I don’t have time for unit tests”, who are the ones that find it hard to convince their bosses/customers they now need 40% more time to develop those changes.

    And at what point is the amount of refactoring that’s required to implement unit tests into existing code more risky than not having the unit tests. Does that depend on when you’re planning on making it a legacy application?

    As always, putting unit tests into new code is far easier than trying to unit test existing code that wasn’t written with IOC etc in mind. Decisions, decisions…

  2. Max Pool on November 14th, 2007 8:00 am

    @Neil –

    This of course is why I am saying to start measuring how much time you are wasting. It is easy to sell unit testing then when it is pitched like this:

    “Can I spend 40% more time building tests, so I can quit wasting 70% of my time fixing bugs that shouldn’t have occurred?”

  3. James Golick on November 14th, 2007 10:26 am

    I think even before the “oh shit” moments, you’re probably spending enough time manually testing your code that you would pretty much break even writing unit tests.

    At some point, after you write a portion of code, you run it. Then, you look at the results, and if something is broken, you try to fix it, and then run the code again, repeating this process until you see that the code works as expected. I would argue that the time it takes to write the unit tests is usually about equal to the time it takes to perform that manual process over and over again, not to mention the time it saves on regressions, and elsewhere.

    For more on that, I wrote an essay on the topic that can be found here:

  4. Justin Deltener on November 14th, 2007 11:54 am

    Damn you Max. 4 oh shits in 4 hours isn’t a good start to my day…especially if it even remotely implies you’re right!

  5. Seth Schubert on November 14th, 2007 3:13 pm

    I’m luckily in the position where my company has embraced automated testing – the applications I’ve built over the last several months were allowed development time to write comprehensive automated tests suites. We still have the occasional “oh shit” due to the fact that even good test suite with decent coverage won’t catch everything, but nothing on the level of applications I’ve dealt with in the past. I can honestly say testing is worth the time from real world experience. Just my 2 pennies ;).

  6. Daily Dose of Links - 20071116 « Daily Geek Bits on November 16th, 2007 6:43 am

    […] Don’t Unit Test? Start Counting Your "Oh Shits!" (via Arjan’s World) […]

  7. Caffeinated Coder on December 3rd, 2007 7:54 am

    The November 2007 Caffeinated Codey Winners Are…

    The November 2007 Caffeinated Codey Winners Are…

  8. Caffeinated Coder » 2007 Caffeinated Codey Final Showdown on January 8th, 2008 12:06 am

    […] Pool for Don’t Unit Test? Start Counting Your “Oh Shits!” [Nov […]

  9. Caffeinated Coder » Blog Archive » 2007 Caffeinated Codey Final Showdown on January 9th, 2008 1:07 am

    […] Pool for Don’t Unit Test? Start Counting Your “Oh Shits!” [Nov […]

  10. Caffeinated Coder >> Russell Ball » The November 2007 Caffeinated Codey Winners Are… on January 14th, 2008 10:41 pm

    […] Most Persuasive TDD argument…Max Pool for his post Don’t Unit Test? Start Counting Your “Oh Shits!”. I had to quit counting my own exclamations after a few hours because I ran out of fingers and toes, […]

Max Pool - © 2024 - {codesqueeze}. Sycorr Banking Solutions