DevOps Zone is brought to you in partnership with:

Michael Norton (doc) is Director of Engineering for Groupon in Chicago, IL. Michael's experience covers a wide range of development topics. Michael declares expertise in no single language or methodology and is immediately suspicious of anyone who declares such expertise. Michael is a DZone MVB and is not an employee of DZone and has posted 41 posts at DZone. You can read more from them at their website. View Full User Profile

TDD is to Code Coverage as Exercise is to Weight Loss

11.09.2013
| 10903 views |
  • submit to reddit

 This is a quick post, following up on a tweet from a little while back:


A great number of people in the software field appear to think the primary benefit of unit tests is test coverage. Some even talk about them as if they were one and the same. "No need for more unit tests, we have plenty of coverage already."

But code coverage is not the point of unit tests. Code coverage is a side affect. Some would say that the point of unit tests is to ensure a discrete piece of code does what you intend. This is a benefit. And a significant one at that. Others would say the point of unit tests is to influence design at a low-level. And here I think we're getting closer to the crux of it. Code that is easy to test is discrete, it has few dependencies (if any), and it serves one and only one purpose. When you have an entire system that is comprised of these small, easily testable pieces of code, you have a significantly higher probability that the system itself is malleable, flexible, extendable ... healthy.

The point of unit tests is to help ensure you are building and maintaining a healthy system.

 

 

Published at DZone with permission of Michael Norton, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Dhananjay Nene replied on Tue, 2013/11/12 - 5:04am

I understood your tweet. But have a great difficulty understanding the title of this post. ie.

TDD is to Code Coverage as exercise is to weight loss

considering the post does not explore the relationship between TDD and code coverage, in fact it does not talk about TDD at all.

James Dykes replied on Wed, 2013/11/13 - 6:56am in response to: Dhananjay Nene

Agreed, absolutely pointless posting. 

Michael Norton replied on Wed, 2013/11/13 - 9:49am in response to: Dhananjay Nene

Good point. I published the article under this ("TDD...") title, realized the error, and later corrected it. Unfortunately, edits after initial publish often don't get picked up in syndication. The article was meant to explain my thinking behind the original tweet, not to talk about TDD.

Dhananjay Nene replied on Wed, 2013/11/13 - 10:17am in response to: Michael Norton

You should be able to update it yourself. Click on the "Edit" link just below DZone - DEVOPSZONE after you've logged in. (At least I am able to do it for my posts which get syndicated to Dzone).



Michael Norton replied on Wed, 2013/11/13 - 10:35am in response to: Dhananjay Nene

Strange. I cannot seem to find a way to edit the article. No "Edit" link on the page. Can't edit from my profile either...


Jon Davis replied on Sat, 2013/11/16 - 5:42pm in response to: Michael Norton

Contact DZone. As a fellow MVB I've found that they copy/paste as DZone articles and often do a decent job at editing and clean-up (primarily to match DZone formatting) but as they don't give you post-publish editing features you have to ask them to make a manual update. Make sure you have everything in order before you do.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.