Monday, November 9, 2009

How many tests are enough?

I've been thinking recently, "How do I know when I've written enough tests?" The answer came to me in a scenario - I've just finished working on a complicated module, and somebody on my team says, "I need to change some of your code to make my stuff work."

Now, I don't know about you, but I'm protective of my code. It feels like one of my kids. I created it. I put my heart and soul into it. I'm proud of it. I want you to like it, admire it, respect it (and me), but I certainly don't want you messing it up.

So when faced with this scenario, what is my reaction? "No, don't touch that! It took me three days to write it." Or is it, "Sure, just keep the tests passing"?

To me, that sums up everything there is to say about test coverage. Not that test coverage tools and metrics aren't important. They give valuable feedback. But, the bottom line is that tests protect your code. Do you feel safe putting it out into the wild?

3 comments:

  1. I just wrote you on linked in as well, but decided to check out your blog. I had something I wanted to run by you, give me a call when you a free minute! 703-465-8000

    ReplyDelete
  2. Collective code ownership helps with us. Trust the tests, trust your team, grow with your code! You should write more. :)

    ReplyDelete
    Replies
    1. I should indeed. I'm amazed that you came across my (very small) blogging footprint. Thanks for taking the time to comment.

      Delete