'Excluding complete modules from jacoco coverage
I have a multi-module project like lets say below:
Project
|-- DataModule
|-- LogicModule
|-- ServiceClientModule
In this project the service client will just implement calls to any services I'm calling and DataModule will just be data classes. Currently jacoco considers all of these modules. Is there a way to exclude complete modules like DataModule or ServiceClientModule since there's no need for UTs in both those cases?
Solution 1:[1]
To generate a report for a multi-module Maven project, here is how it needs to be setup.
parent/
??? child1
??? child2
??? jacoco-reports <-- Adds dependency for child1 and child2 modules
??? pom.xml
When you run the build to generate the aggregate report using the report-aggregate
goal, the coverage report is generated in the jacoco-reports
module for the entire project.
With this setup, you can pick and chose the modules for which the report is generated.
Here is my article for using jacoco-maven-plugin with multi-module Maven projects.
Solution 2:[2]
if you are using maven, you can add a profile in the root pom (where the modules are specified), where you specify the plugin in a plugin management section. in each module you want to run jacoco, you have to reference the plugin. it will generate the site folder only in the modules where you need the jacoco report.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Laura Liparulo |