22 April 2011

Discussion on code coverage

100% Code Coverage! | Javalobby. The fundamental point is you need to look at more than just code coverage. If you haven't though hard enough about your test cases you could have a system that is well covered (in the code coverage sense) but is not well tested.
If you have 100% coverage you don’t know if your system works, but you _do_ know that every line you wrote does what you thought it should.

Thus, code coverage and test are completely different things. Taken to the extreme, we could code-cover the entire application, that is achieve 100%, and not test a single line because we have no assertion!

Not all of our code is neither critical nor complex. In fact, some can even seen as downright trivial. Any doubt? Think about getters and setter then. Should they be tested, even though any IDE worth his salt can generate them faithfully for us? If your answer is yes, you should also consider testing the frameworks you use, because they are a bigger source of bugs than generated getters and setters.

No comments:

Post a Comment