I like this statement: The 100% coverage practice is costly only when it forces substandard code to be well designed.

And it is from a post of Patrick Smacchia on simple-talk.

Patrick wrote an essay about writing unit testing code in c#, in which I personally found a lot of good points that I could not agree more. For example:

  • Not all classes need to be 100% covered by tests or even covered at all.
  • The 100% coverage practice is costly only when it forces substandard code to be well designed.

And especially for the second one, I think it is inspirational and encouraging. I faced situations from time to time that for some certain pieces of codes/logic, it was difficult to write a comprehensive test suite to cover all the branches. Honestly, most of time when I faced this, I will choose to leave the coverage not to 100% and accept the fact. But after reading this, from now on, I will try my best to achieve the 100% coverage by not only writing comprehensive test cases, but also refactoring the “difficult” logic to the best designed, intuitive, and enjoyable to read codes.

I like this statement: The 100% coverage practice is costly only when it forces substandard code to be well designed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s