Skip to content

Commit d998b7f

Browse files
committed
Updated README.md file
1 parent ff08836 commit d998b7f

File tree

2 files changed

+80
-41
lines changed

2 files changed

+80
-41
lines changed

README.md

Lines changed: 80 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ A custom Maven plugin that generates a textual tree-like coverage report from Ja
1111
- Multi-module project support with option to defer reporting until the end
1212
- Automatic scanning for `jacoco.exec` files across modules
1313
- Support for custom JaCoCo execution file patterns
14+
- Combined weighted coverage score based on customizable weights
1415

1516
## Prerequisites
1617
- Maven 3.x
@@ -52,73 +53,118 @@ Ensure the JaCoCo plugin has executed beforehand to generate jacoco.exec.
5253
|-----------------------|-----------------------------------------------------------|------------------------------------------|
5354
| `jacocoExecFile` | Path to the JaCoCo execution data file | `${project.build.directory}/jacoco.exec` |
5455
| `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` |
5760
| `scanModules` | Automatically scan for exec files in project modules | `false` |
5861
| `baseDir` | Base directory for module scanning | `${project.basedir}` |
5962
| `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` |
6067

61-
## Example Output
68+
## Default Output
6269
```text
6370
[INFO] Overall Coverage Summary
64-
[INFO] Package | Class, % | Method, % | Branch, % | Line, %
71+
[INFO] Package Class, % Method, % Branch, % Line, %
6572
[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)
7276
[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%)
74107
```
75108

76109
## Advanced Usage
77110

78111
### Multi-Module Projects
79112

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:
81120

82121
```xml
83122
<plugin>
84123
<groupId>io.github.svaningelgem</groupId>
85124
<artifactId>jacoco-console-reporter</artifactId>
86125
<version>1.0.0</version>
87126
<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>
95128
</configuration>
96-
<executions>
97-
<execution>
98-
<goals>
99-
<goal>report</goal>
100-
</goals>
101-
<phase>verify</phase>
102-
</execution>
103-
</executions>
129+
<!-- ... -->
104130
</plugin>
105131
```
106132

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
110134

111-
### Custom JaCoCo File Locations
135+
You can configure which parts of the report are displayed:
112136

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:
114157

115158
```xml
116159
<plugin>
117160
<groupId>io.github.svaningelgem</groupId>
118161
<artifactId>jacoco-console-reporter</artifactId>
119162
<version>1.0.0</version>
120163
<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>
122168
</configuration>
123169
<!-- ... -->
124170
</plugin>
@@ -134,6 +180,7 @@ The plugin works by:
134180
4. Building a hierarchical directory structure representing the package organization
135181
5. Calculating coverage metrics (class, method, branch, line) for each node
136182
6. Generating a tree-like report to the console
183+
7. Computing a weighted combined coverage score
137184

138185
## Contributing
139186

pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,6 @@
160160
</dependencyManagement>
161161

162162
<build>
163-
<extensions>
164-
<extension>
165-
<groupId>org.apache.maven.extensions</groupId>
166-
<artifactId>maven-build-cache-extension</artifactId>
167-
<version>1.2.0</version>
168-
</extension>
169-
</extensions>
170-
171163
<pluginManagement>
172164
<plugins>
173165
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->

0 commit comments

Comments
 (0)