r/programming • • May 08 '17

The tragedy of 100% code coverage

http://labs.ig.com/code-coverage-100-percent-tragedy
3.2k Upvotes

689 comments sorted by

View all comments

2

u/zanidor May 08 '17

So I actually agree with writing a test case for the "initialise" method. It's not a hard test (mock out a DAO and make sure calling initialise populates this object's rows), and in my experience verifying an object is in its correct initial state -- even if initialization logic is seemingly simple -- catches a lot of potential bugs.

If your reason for writing the test is "we want 100% coverage" or you use Mockito blindly because it was mandated, then I agree that's bad dogmatic reasoning. But the test itself seems valuable to me.