I've developed a java annotation processor (here is a good tutorial). I would like to get code coverage of the generated source code and have had no luck. I use maven as the build tool. Note that the class names of the generated source files contain '$$' to minimize the chance of class name collision (e.g., my/package/Foo$$Bar.java). The root of the source tree is target/generated-test-sources/test-annotations (maven's standard location for sources generated during a test compile).
How do I configure the clover maven plugin such that clover2:setup instruments these generated sources?
When using Clover with any code source generation user must ensure code generation happens before Clover instrumentation happens.
With code annotation processors this is a tricky part because those are processed in-the-fly by Java compiler.
What you may want to experiment with is to process the annotations via some plugin, make sure it's invoked before Clover.
Out of curiosity, why do you want to track coverage for a generated code? Usually it's a boilerplate code without any valid business logic in it.
Thanks for the explanation and suggestion.
You're correct that it basically generates boilerplate code, but different annotation combinations interact with each other. I have tests that verify the interaction... since I have tests, I want code coverage.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.