Are 100% code coverage reasonable?
When you use a code coverage tool one of the first question is what is a good code coverage. Recently I listened to different podcasts (stackoverflow, scott hanselman) where they discuss this topic. I wasn’t really surprised that there wasn’t one unique opinion.
One opinion was that 100% is a good number, an other opinion was that for non-failing code it doesn’t make sense to build a test, so 100% isn’t a good number for most of the projects.
The last opinion sounds not that bad, but for which code it doesn’t make sense to build unit tests?
Here is a (not complete) list of code elements for which I wouldn’t build a unit-test:
- Properties (.Net)
- Getters (Java)
- Setters (Java)
- Primitive Constructors (no chaining, no big logic in it)
- Services (which just delegate to the business logic)
- GUI (Views)
- Data Access (do not test a framework)
- Services of another component or another application (do not test a library or another application)
- Any Generated Code (do not test a tool, in this case a code generator)
Is there a code element or type which I forget?