1

I have added configuration with excluded files in jacoco maven plugin but coverage under jacoco.exec is not reflecting to exclude files

I already tried adding exclusion at level: coverage-check, coverage-report, post-integration-test as well as directly under plugin level. Exclude option is working only for index.html file but coverage under jacoco.exec is not reflecting to exclude files . One of example fo exclusion:

                        <id>coverage-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <!--<dataFile>target/jacoco.exec</dataFile>-->
                            <rules>
                                <rule implementation="org.jacoco.maven.RuleConfiguration">
                                    <!--<element>CLASS</element>-->
                                    <excludes>
                                        <exclude>**/*/com/xyz/*.class</exclude>
</excludes>
</rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>

line coverage in index.html is coming as 64% but jacoco.exec shows coverage as 23% only

user1575601
  • 397
  • 1
  • 7
  • 20
  • Possible duplicate of [How to specify the specific packages for the 'jacoco-check'?](https://stackoverflow.com/questions/54055625/how-to-specify-the-specific-packages-for-the-jacoco-check) – Godin Aug 22 '19 at 03:43
  • I added my answer here which might help: https://stackoverflow.com/a/69352172/9813464 – Ash Sep 27 '21 at 19:25

1 Answers1

1

Please carefully read https://www.jacoco.org/jacoco/trunk/doc/check-mojo.html#rules :

excludes inside rule specifies name of element

So in case of commented-out

<!--<element>CLASS</element>-->

default value of element is BUNDLE and so excludes should specify names of BUNDLEs

In case of

<element>CLASS</element>

<exclude>**/*/com/xyz/*.class</exclude>

won't work, because excludes is not about names of files - they are about names of classes and instead / they have . and don't have .class at the end.

Godin
  • 9,801
  • 2
  • 39
  • 76