13

I am looking for a way to exclude specific class methods in my jacoco analysis. I am aware of the "excludes" property but that only applies to entire classes.

In my case i have generated methods that distort the coverage report so i would like to exclude them from the report.

Moritz
  • 10,124
  • 7
  • 51
  • 61

2 Answers2

1

JaCoCo supports now (in 2018, I know the question is from 2012) since version 0.8.0 (released on 2018/01/02) ignoring methods with annotion @lombok.Generated.

So this can be used as a workaround also for other generated methods (if you are able to tag them this way) or even for "hand-written" methods if you really want (although this was probably not the intention of the authors).

Mayoares
  • 1,234
  • 2
  • 13
  • 21
-1

You can actually use wildcards in the excludes property, that is if you're using ant to run the jacoco unit test:

Blockquote excludes - A list of class names that should be excluded from execution analysis. The list entries are separated by a colon (:) and may use wildcard characters (* and ?). Except for performance optimization or technical corner cases this option is normally not required. http://www.eclemma.org/jacoco/trunk/doc/ant.html

You can also exclude files from the report generation process using simple ant fileset tasks:

<jacoco:report>    
    <executiondata>
        <file file="jacoco.exec"/>
    </executiondata>

    <structure name="Example Project">
        <classfiles>
            <fileset dir="classes"/>
        </classfiles>
        <sourcefiles encoding="UTF-8">
            <fileset dir="src"/>
        </sourcefiles>
    </structure>

    <html destdir="report"/>

</jacoco:report>

You may have to experiment with the two to get the desired results.

Jason Huntley
  • 3,827
  • 2
  • 20
  • 27