I am trying to set up Cobertura code coverage on a project which includes auto-generated code, created from templates using Freemarker (explicitly, using the fmpp maven plugin).
I then have unit tests for those auto-generated classes.
However, these unit tests are not being considered by Cobertura when calculating code coverage. The auto-generated classes appear in the report, but the coverage on those classes is always 0%.
First, is there some configuration for Cobertura that I'm missing?
This SO question appears to have been asking a similar question, but the accepted answer is that:
Generated code should not be tested and should not be used in code coverage metrics.
This does not seem right to me - I think I should be testing the generated code (both to test the generated classes and the templates), and I want to know how the code coverage for this generated code.
So, second, is there a good reason why generated code shouldn't be tested?
Edit: It's also relevant to mention that I am using cobertura using the cobertura-maven-plugin. As such, I'm not sure if the problem is with cobertura or the maven-plugin (or my configuration thereof...)
N.b. to be clear, I am not asking about auto-generating the test classes. These are manually written, to test the classes created from templates.