Skip to content

Commit 923033e

Browse files
committed
add JaCoCo coverage reporting
1 parent 5fe2457 commit 923033e

File tree

3 files changed

+53
-11
lines changed

3 files changed

+53
-11
lines changed

.github/workflows/spring-boot.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ jobs:
3131
distribution: "temurin"
3232
cache: maven
3333

34-
- name: Build
35-
run: ./mvnw -B clean install -DskipTests
36-
3734
- name: Lint
3835
run: ./mvnw -B spotless:check
3936

40-
- name: Unit tests
41-
run: ./mvnw -B test
37+
- name: Test
38+
run: ./mvnw -B clean verify
4239

43-
- name: Integration tests
44-
run: ./mvnw -B failsafe:integration-test failsafe:verify
40+
- name: Upload JaCoCo report
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: jacoco-report
44+
path: backend/spring-boot/target/site/jacoco/
4545

4646
push-image:
4747
needs: build

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Bugzkit is a production-ready full-stack web application template with a Spring
1414
|---|---------------------------------------------------------|
1515
| Build (skip tests) | `./mvnw -B clean install -DskipTests` |
1616
| Run (dev profile) | `./mvnw spring-boot:run -Dspring-boot.run.profiles=dev` |
17-
| Unit tests | `./mvnw -B test` |
18-
| Integration tests | `./mvnw -B failsafe:integration-test failsafe:verify` |
17+
| All tests + coverage | `./mvnw -B clean verify` (report: `target/site/jacoco/`) |
18+
| Unit tests only | `./mvnw -B test` |
1919
| Format check | `./mvnw -B spotless:check` |
2020
| Format fix | `./mvnw spotless:apply` |
2121

backend/spring-boot/pom.xml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,22 +214,64 @@
214214
</annotationProcessorPaths>
215215
</configuration>
216216
</plugin>
217+
<plugin>
218+
<groupId>org.apache.maven.plugins</groupId>
219+
<artifactId>maven-failsafe-plugin</artifactId>
220+
<executions>
221+
<execution>
222+
<goals>
223+
<goal>integration-test</goal>
224+
<goal>verify</goal>
225+
</goals>
226+
</execution>
227+
</executions>
228+
</plugin>
217229
<plugin>
218230
<groupId>org.jacoco</groupId>
219231
<artifactId>jacoco-maven-plugin</artifactId>
220232
<version>${jacoco.version}</version>
221233
<executions>
222234
<execution>
235+
<id>prepare-agent</id>
223236
<goals>
224237
<goal>prepare-agent</goal>
225238
</goals>
226239
</execution>
227240
<execution>
228-
<id>generate-code-coverage-report</id>
229-
<phase>test</phase>
241+
<id>prepare-agent-integration</id>
242+
<goals>
243+
<goal>prepare-agent-integration</goal>
244+
</goals>
245+
</execution>
246+
<execution>
247+
<id>merge-coverage</id>
248+
<phase>post-integration-test</phase>
249+
<goals>
250+
<goal>merge</goal>
251+
</goals>
252+
<configuration>
253+
<fileSets>
254+
<fileSet>
255+
<directory>${project.build.directory}</directory>
256+
<includes>
257+
<include>jacoco.exec</include>
258+
<include>jacoco-it.exec</include>
259+
</includes>
260+
</fileSet>
261+
</fileSets>
262+
<destFile>${project.build.directory}/jacoco-merged.exec</destFile>
263+
</configuration>
264+
</execution>
265+
<execution>
266+
<id>report</id>
267+
<phase>verify</phase>
230268
<goals>
231269
<goal>report</goal>
232270
</goals>
271+
<configuration>
272+
<dataFile>${project.build.directory}/jacoco-merged.exec</dataFile>
273+
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
274+
</configuration>
233275
</execution>
234276
</executions>
235277
</plugin>

0 commit comments

Comments
 (0)