Over a million developers have joined DZone.
Platinum Partner

TDD is to Code Coverage as Exercise is to Weight Loss

· DevOps Zone

The DevOps Zone is brought to you in partnership with New Relic.  Learn more about the common barriers to DevOps adoption so that you can come up with ways to win over the skeptics and kickstart DevOps.

 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.

 

 

The DevOps Zone is brought to you in partnership with New Relic. Quickly learn how to use Docker and containers in general to create packaged images for easy management, testing, and deployment of software.

Topics:

Published at DZone with permission of Michael Norton , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}