@@ -11,6 +11,7 @@ A custom Maven plugin that generates a textual tree-like coverage report from Ja
11
11
- Multi-module project support with option to defer reporting until the end
12
12
- Automatic scanning for ` jacoco.exec ` files across modules
13
13
- Support for custom JaCoCo execution file patterns
14
+ - Combined weighted coverage score based on customizable weights
14
15
15
16
## Prerequisites
16
17
- Maven 3.x
@@ -52,73 +53,118 @@ Ensure the JaCoCo plugin has executed beforehand to generate jacoco.exec.
52
53
| -----------------------| -----------------------------------------------------------| ------------------------------------------|
53
54
| ` jacocoExecFile ` | Path to the JaCoCo execution data file | ` ${project.build.directory}/jacoco.exec ` |
54
55
| ` classesDirectory ` | Directory containing compiled classes | ` ${project.build.outputDirectory} ` |
55
- | ` deferReporting ` | Defer reporting until the end (for multi-module projects) | ` false ` |
56
- | ` showFiles ` | Whether to show individual source files in the report | ` true ` |
56
+ | ` deferReporting ` | Defer reporting until the end (for multi-module projects) | ` true ` |
57
+ | ` showFiles ` | Whether to show individual source files in the report | ` false ` |
58
+ | ` showTree ` | Whether to show the tree structure in the report | ` true ` |
59
+ | ` showSummary ` | Whether to show the summary information | ` true ` |
57
60
| ` scanModules ` | Automatically scan for exec files in project modules | ` false ` |
58
61
| ` baseDir ` | Base directory for module scanning | ` ${project.basedir} ` |
59
62
| ` additionalExecFiles ` | Additional exec files to include in the report | ` [] ` |
63
+ | ` weightClassCoverage ` | Weight for class coverage in combined score | ` 0.1 ` |
64
+ | ` weightMethodCoverage ` | Weight for method coverage in combined score | ` 0.1 ` |
65
+ | ` weightBranchCoverage ` | Weight for branch coverage in combined score | ` 0.4 ` |
66
+ | ` weightLineCoverage ` | Weight for line coverage in combined score | ` 0.4 ` |
60
67
61
- ## Example Output
68
+ ## Default Output
62
69
``` text
63
70
[INFO] Overall Coverage Summary
64
- [INFO] Package | Class, % | Method, % | Branch, % | Line, %
71
+ [INFO] Package │ Class, % │ Method, % │ Branch, % │ Line, %
65
72
[INFO] --------------------------------------------------------------------------------------------------------------------------------------------------------
66
- [INFO] com.example | 100.00% (3/3) | 83.33% (5/6) | 50.00% (2/4) | 75.00% (15/20)
67
- [INFO] ├─model | 100.00% (1/1) | 100.00% (2/2) | 50.00% (1/2) | 87.50% (7/8)
68
- [INFO] │ └─Model.java | 100.00% (1/1) | 100.00% (2/2) | 50.00% (1/2) | 87.50% (7/8)
69
- [INFO] ├─util | 100.00% (1/1) | 100.00% (2/2) | 50.00% (1/2) | 87.50% (7/8)
70
- [INFO] │ └─Util.java | 100.00% (1/1) | 100.00% (2/2) | 50.00% (1/2) | 87.50% (7/8)
71
- [INFO] └─Example.java | 100.00% (1/1) | 33.33% (1/2) | 0.00% (0/0) | 25.00% (1/4)
73
+ [INFO] com.example │ 100.00% (3/3) │ 83.33% (5/6) │ 50.00% (2/4) │ 75.00% (15/20)
74
+ [INFO] ├─model │ 100.00% (1/1) │ 100.00% (2/2) │ 50.00% (1/2) │ 87.50% (7/8)
75
+ [INFO] └─util │ 100.00% (1/1) │ 100.00% (2/2) │ 50.00% (1/2) │ 87.50% (7/8)
72
76
[INFO] --------------------------------------------------------------------------------------------------------------------------------------------------------
73
- [INFO] all classes | 100.00% (3/3) | 83.33% (5/6) | 50.00% (2/4) | 75.00% (15/20)
77
+ [INFO] all classes │ 100.00% (3/3) │ 83.33% (5/6) │ 50.00% (2/4) │ 75.00% (15/20)
78
+ [INFO] Overall Coverage Summary
79
+ [INFO] ------------------------
80
+ [INFO] Class coverage : 100.00% (3/3)
81
+ [INFO] Method coverage: 83.33% (5/6)
82
+ [INFO] Branch coverage: 50.00% (2/4)
83
+ [INFO] Line coverage : 75.00% (15/20)
84
+ [INFO] Combined coverage: 68.33% (Class 10%, Method 10%, Branch 40%, Line 40%)
85
+ ```
86
+
87
+ ## Output with all options on
88
+ ``` text
89
+ [INFO] Overall Coverage Summary
90
+ [INFO] Package │ Class, % │ Method, % │ Branch, % │ Line, %
91
+ [INFO] --------------------------------------------------------------------------------------------------------------------------------------------------------
92
+ [INFO] com.example │ 100.00% (3/3) │ 83.33% (5/6) │ 50.00% (2/4) │ 75.00% (15/20)
93
+ [INFO] ├─model │ 100.00% (1/1) │ 100.00% (2/2) │ 50.00% (1/2) │ 87.50% (7/8)
94
+ [INFO] │ └─Model.java │ 100.00% (1/1) │ 100.00% (2/2) │ 50.00% (1/2) │ 87.50% (7/8)
95
+ [INFO] ├─util │ 100.00% (1/1) │ 100.00% (2/2) │ 50.00% (1/2) │ 87.50% (7/8)
96
+ [INFO] │ └─Util.java │ 100.00% (1/1) │ 100.00% (2/2) │ 50.00% (1/2) │ 87.50% (7/8)
97
+ [INFO] └─Example.java │ 100.00% (1/1) │ 33.33% (1/2) │ 0.00% (0/0) │ 25.00% (1/4)
98
+ [INFO] --------------------------------------------------------------------------------------------------------------------------------------------------------
99
+ [INFO] all classes │ 100.00% (3/3) │ 83.33% (5/6) │ 50.00% (2/4) │ 75.00% (15/20)
100
+ [INFO] Overall Coverage Summary
101
+ [INFO] ------------------------
102
+ [INFO] Class coverage : 100.00% (3/3)
103
+ [INFO] Method coverage: 83.33% (5/6)
104
+ [INFO] Branch coverage: 50.00% (2/4)
105
+ [INFO] Line coverage : 75.00% (15/20)
106
+ [INFO] Combined coverage: 68.33% (Class 10%, Method 10%, Branch 40%, Line 40%)
74
107
```
75
108
76
109
## Advanced Usage
77
110
78
111
### Multi-Module Projects
79
112
80
- For multi-module projects, you can configure the plugin to aggregate coverage across modules. All configuration values are the defaults so they don't have to be added, but are shown here for completeness’s sake:
113
+ The plugin is configured by default to defer reporting until the end.
114
+
115
+ This will wait with generating the report until the last module in the build.
116
+
117
+ ### Custom JaCoCo File Locations
118
+
119
+ If your JaCoCo plugin uses a non-default location for the execution data file:
81
120
82
121
``` xml
83
122
<plugin >
84
123
<groupId >io.github.svaningelgem</groupId >
85
124
<artifactId >jacoco-console-reporter</artifactId >
86
125
<version >1.0.0</version >
87
126
<configuration >
88
- <jacocoExecFile >${project.build.directory}/jacoco.exec</jacocoExecFile >
89
- <classesDirectory >${project.build.outputDirectory}</classesDirectory >
90
- <deferReporting >true</deferReporting >
91
- <showFiles >true</showFiles >
92
- <additionalExecFiles />
93
- <scanModules >false</scanModules >
94
- <baseDir >${project.basedir}</baseDir >
127
+ <jacocoExecFile >${project.build.directory}/custom-jacoco.exec</jacocoExecFile >
95
128
</configuration >
96
- <executions >
97
- <execution >
98
- <goals >
99
- <goal >report</goal >
100
- </goals >
101
- <phase >verify</phase >
102
- </execution >
103
- </executions >
129
+ <!-- ... -->
104
130
</plugin >
105
131
```
106
132
107
- This configuration will:
108
- - Defer the reporting until the last module in the build
109
- - Automatically scan for JaCoCo execution files in all modules
133
+ ### Customizing Report Output
110
134
111
- ### Custom JaCoCo File Locations
135
+ You can configure which parts of the report are displayed:
112
136
113
- If your JaCoCo plugin uses a non-default location for the execution data file:
137
+ ``` xml
138
+ <plugin >
139
+ <groupId >io.github.svaningelgem</groupId >
140
+ <artifactId >jacoco-console-reporter</artifactId >
141
+ <version >1.0.0</version >
142
+ <configuration >
143
+ <!-- Show or hide the tree structure -->
144
+ <showTree >true</showTree >
145
+ <!-- Show or hide individual source files -->
146
+ <showFiles >true</showFiles >
147
+ <!-- Show or hide the summary information -->
148
+ <showSummary >true</showSummary >
149
+ </configuration >
150
+ <!-- ... -->
151
+ </plugin >
152
+ ```
153
+
154
+ ### Customizing Coverage Weights
155
+
156
+ You can adjust the weights used to calculate the combined coverage score:
114
157
115
158
``` xml
116
159
<plugin >
117
160
<groupId >io.github.svaningelgem</groupId >
118
161
<artifactId >jacoco-console-reporter</artifactId >
119
162
<version >1.0.0</version >
120
163
<configuration >
121
- <jacocoExecFile >${project.build.directory}/custom-jacoco.exec</jacocoExecFile >
164
+ <weightClassCoverage >0.2</weightClassCoverage >
165
+ <weightMethodCoverage >0.2</weightMethodCoverage >
166
+ <weightBranchCoverage >0.3</weightBranchCoverage >
167
+ <weightLineCoverage >0.3</weightLineCoverage >
122
168
</configuration >
123
169
<!-- ... -->
124
170
</plugin >
@@ -134,6 +180,7 @@ The plugin works by:
134
180
4 . Building a hierarchical directory structure representing the package organization
135
181
5 . Calculating coverage metrics (class, method, branch, line) for each node
136
182
6 . Generating a tree-like report to the console
183
+ 7 . Computing a weighted combined coverage score
137
184
138
185
## Contributing
139
186
0 commit comments