I am trying to exclude certain methods from Unit test coverage. I am using Cobertura because I found out that since version 2.0 they introduced a coverage ignore annotation for excluding methods and classes: https://github.com/cobertura/cobertura/wiki/Coverage-Annotations
I set up my project as it should be, created a @interface called "CoverageIgnore" as it is in the article and annotated some methods. I am using Cobertura 2.0.3 and when generating the report the annotations don't seem to work :(
I found this article also - https://github.com/cobertura/cobertura/wiki/Ant-Task-Reference#ignore-method-annotation which talks about some configuration of the instrument task in cobertura but it seems to be Ant-compliant:
<cobertura-instrument>
<ignoreMethodAnnotation annotationName="foo.bar.CoverageIgnore"/>
</cobertura-instrument>
Is there something like this for my maven project? Thanks.
Try this:
Notice that this is in the
<build>
element. I have not tried it in the<reporting>
element, but I know that<ignore>
and<exclude>
only work in<build>
, so it wouldn't surprise me if the ignore annotations don't work there either.