Yesterday I had the opportunity to hop on over to Oklahoma City for an Extreme Programming Workshop being given by Raymond Lewallen (thanks again Raymond).
In the midst of discussing the practice of Test Driven Development, Raymond asked me how many lines of unit test code I typically write per line of actual code. Not having used any line counters or code metrics software, I threw out a best guess number off the top of my head……oh, maybe 10 lines.
10 lines of unit testing code for each line of actual code!?
The more I thought about it, the more that number sounded pretty high to me. And Raymond mentioned that his average was typically around 17 to 10 or 1.7 unit test lines per actual line. So, I decided to do some investigating.
I fired up a line counting tool that Raymond had mentioned in his talk called countlines and pointed it to my most recent project. Here’s the verdict:
Actual lines: 3868
Unit Test lines: 4065
Ratio: 1.05 unit test lines per actual
While somewhat embarrassed that I was so grossly inaccurate, I wanted to share this especially with anybody else attending yesterday that might read my blog, as I find this number to be more reasonable and hopefully more in line with what others are experiencing – which I’d love to hear about!
What kind of ratios are you seeing on your projects?