How to exclude generated code from jacoco coverge report?

129 Views Asked by At

I have a maven project and the below step is mentioned right after executing surefire tests(for JUnit) and failsafe (for Integration tests). However, I am not able to exclude the files from generated-sources folder. However, if I use a single exclusionPattern:'/tomcat/', it is excluding tomcat folder from the report

I have tried below option:

**```
post {
    always {
        junit allowEmptyResults: true, testResults: '**/target/failsafe-reports/*.xml'
        step( [ $class: 'JacocoPublisher', exclusionPattern: '**/target/generated-sources/**,**/tomcat/**'] )
    }
}
```**

but it is only excluding the tomcat folders and not the generated-sources. Still seeing files from this folder in coverage report.

1

There are 1 best solutions below

0
Ankit Singh On

As a workaround, I am targeting the java packages inside target directory to improve coverage. It's not a very efficient way to do it as I had to add entries for multiple packages inside exclusionPattern. But, it works well for my requirement.