While reading Scott Bain’s great book Emergent Design, I was reminded of a story. It took place a couple of years ago inside a very tall building in a very large city. I was giving an early version of my Test Driven Development workshop. There were about 25 developers to entertain. I asked the standard calibration questions:

–    How many of you are doing TDD now? Answer: none
–    How many of you do unit testing? Answer: none
–    How many of you know what unit testing is? Answer: some
–    Of those of you who know what it is, do you think it is a good idea? Answer: yes
–    Why, then, do you not do it? Answer: we don’t have time

It was not an unusual set of answers, of course. I have had that same dialog with more than one group.

I went through my presentation and covered a lot of ground. Just before lunch I talked about code coverage and gave a demonstration using the whimsically named Eclipse plug-in Coverlipse. One of the participants was particularly interested by the concept, the fellow who had stated that no one had time for unit testing. He had accepted my invitation to bring work to the class in order to try out TDD on something familiar rather than doing the exercises I provided. He wanted to try code coverage and asked to use my machine during lunch because we could not get a network connection in the room for him to download Coverlipse.

At the end of the lunch break, I asked if he would share his discoveries with the class. He had been working for about 20 minutes. His code was a caching system for high volume transactions. He had written some unit tests, driven by a desire to maximize code coverage. I explained to the class that this was one approach, not a test-first approach but a valid one once you have a design you are happy with.

As the class reassembled, he was at 60% code coverage. I let him work out loud, projecting on the screen, sharing his strategy. At one point he made a design change based on test results which I pointed out to the class. After about 30 minutes he achieved 87% code coverage. He was very happy. The class was impressed. As he returned to his seat, I began the afternoon session with a reinforcing question:

“Now, what were you saying about not having time to do unit testing? How long did it take you to get to 87% code coverage?”

Print Friendly, PDF & Email
No Time to Unit Test
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: