“I am ready to write some unit tests. What code coverage should I aim for?”
“Don’t worry about coverage, just write some good tests.”
“How many grains of rice should I put in that pot?”
“How can I possibly tell you? It depends on how many people you need to feed, how hungry they are, what other food you are serving, how much rice you have available, and so on.”
“Eighty percent and no less!” Replied the master in a stern voice, pounding his fist on the table.
“Great master, today I overheard you answer the same question about code coverage with three different answers. Why?”
“Come get some fresh tea with me and let’s talk about it.”
“The first programmer is new and just getting started with testing. Right now he has a lot of code and no tests. He has a long way to go; focusing on code coverage at this time would be depressing and quite useless. He’s better off just getting used to writing and running some tests. He can worry about coverage later.
The second programmer, on the other hand, is quite experienced both at programming and testing. When I replied by asking her how many grains of rice I should put in a pot, I helped her realize that the amount of testing necessary depends on a number of factors, and she knows those factors better than I do – it’s her code after all. There is no single, simple, answer, and she’s smart enough to handle the truth and work with that.”
“The third programmer wants only simple answers – even when there are no simple answers … and then does not follow them anyway.”
I think our industry would benefit to have more of the first two people and a whole lot less of the third.
Is this about developers or testers? The story is nice though. But again it looks like the testing is only scripting in your place.
I would say to the experienced dev: "Aim for an increasing trend in code coverage"
The Way of Testivus is the best thing I've seen in a long time. Well done.
The story is definitely not just about code coverage :)
We need great master...........
Just give the consultant answer, "It depends..." :)
Hope that I have a great master who can drink some tea with me. ;)
We need more great masters Basharat
very cool. Thanks for sharing!
Dear Alberto,I would like to translate your post to portuguese and post it on our website, because I have a few coleagues that aren't comfortable reading in english and would benefit from your post. Can I do it?Respectfuly,Júlio
I really like the managers attitude. I wish people would customize to help people with various skills and experience insead of assuming that one set of instructions will get us similar results. This note is really about master understanding his people.
Cool...MasterI guess it is a nice way to let people understand about the code coverage. Or any other question.I guess this is about the attibute of a person how we react in our day to day job.Regarding the Code Coverage. I guess the first answer was quite important. Just try to concentrate on writing the good test, instead of worring about the coverage. It is important to dissuss those test with bussiness, through that a person should be able to figure out the coverage achieved in the test.But nice and cool approach. :)
Really nice story! Perfect introduction to code coverage for developers and project managers in particular!
>I would like to translate your post to portuguese and post it on our website ... Can I do it?<Hi Julio, no problem. I'd love to see Testivus in Portuguese or any other language. Thanks, Alberto
This comment has been removed by the author.
Look into T.D.D., XUnit, and other pre-cog code coverage methodologies that inherently strive for 100% coverage.
This story has earned me huge amount of repu points on StackOverflow: http://stackoverflow.com/questions/90002/what-is-a-reasonable-code-coverage-for-unit-tests-and-why/90021#90021It remains to be one of the most excellent answers to the code coverage issue.
Great story! Love it! Published a german translation here: http://itscertainlyuncertain.blogspot.de/2013/01/testivus-zum-thema-test-coverage.html
100% only! Otherwise people getting squeezed for time will cover getters and setters and leave the tasty stuff.
The comments you read and contribute here belong only to the person who posted them. We reserve the right to remove off-topic comments.