Adam Bien's Weblog
How To Achieve 80% Code Coverage Fast And Painlessly - In Four Steps
80% of code coverage is a common number expected by QA departments. Such a metric is relatively easy to achieve:
- Test simple things first. The simpler, the better.
- Don't use asserts. They don't influence the code coverage and just break the build.
- Don't use
fail, and do not re-throw exceptions - just swallow them. - Sometimes you will have to split complex methods into smaller ones. Names don't matter. Its additional effort, but will increase your code coverage. Goto 1.
:-). Although I never saw all four items in the "field", the use of System.out.println instead of asserts becomes increasingly popular idiom. It is very easy to satisfy the QA department and write completely unmaintainable code at the same time :-).
Posted at 10:29AM Feb 22, 2011 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[5] | Views/Hits: 7571
NEW Workshop: "JPA, NoSQL, Caching, Grids and Distributed Caches with Java EE 7", May 7th, 2013, Airport Munich
A book about rethinking Java EE Patterns
Tweet Follow @AdamBien

Excellent! Bonus points for goto :)
Posted by Robert Kovacevic on February 22, 2011 at 01:27 PM CET #
It's a funny post but I dread ending up working with a dev team in the future that cites your bullet list as a practice they follow.
Would you make the smileys larger please? And maybe add a watermark with the text "This is funny. Laugh." in it?
Posted by Kris on February 22, 2011 at 03:05 PM CET #
I think this post is helpful to me.
Posted by Meteor on March 14, 2011 at 01:26 PM CET #
@Meteor,
your comment is dangerous - this post should not be taken too seriously...:-)
adam
Posted by adam-bien.com on March 14, 2011 at 10:38 PM CET #
@adam
OK. Thanks.
Posted by Meteor on April 03, 2011 at 10:27 AM CEST #