From a65a2a986d282c3cbadc1821572926438121b237 Mon Sep 17 00:00:00 2001 From: "Michael G. Noll" Date: Tue, 7 May 2024 10:40:04 +0200 Subject: [PATCH] Add jacoco for code coverage checks and reports --- README.md | 1 + justfile | 17 ++++++--- pom.xml | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 116 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ef79ccb..61d6872 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Features: - Supports [Docker BuildKit](https://docs.docker.com/build/) - Java 21 (Eclipse Temurin) - [JUnit 5](https://github.com/junit-team/junit5) for testing, + [Jacoco](https://github.com/jacoco/jacoco) for code coverage, [SpotBugs](https://github.com/spotbugs/spotbugs) for static code analysis - Maven for build management, using [Maven Wrapper](https://github.com/apache/maven-wrapper) - Supports GraalVM to create diff --git a/justfile b/justfile index e10b01c..4c7651a 100644 --- a/justfile +++ b/justfile @@ -59,13 +59,18 @@ docker-image-run: @echo "Running container from docker image ..." @./start_container.sh +# clean (remove) the build artifacts +clean: + @./mvnw clean + # compile the project compile: @./mvnw compile -# clean (remove) the build artifacts -clean: - @./mvnw clean +# create coverage report +coverage: verify + @./mvnw jacoco:report && \ + echo "Coverage report is available under {{build_dir}}/site/jacoco/" # static code analysis via infer (requires https://github.com/facebook/infer) infer: @@ -83,6 +88,10 @@ format-check: package: @./mvnw package +# print effective pom.xml +pom: + @./mvnw help:effective-pom + # run the application locally run: #!/usr/bin/env bash @@ -133,7 +142,7 @@ test-integration: upgrade-mvnw: @./mvnw wrapper:wrapper -# run all tests, plus static code analysis with spotbugs +# run all tests, plus coverage check and static code analysis verify: @./mvnw verify diff --git a/pom.xml b/pom.xml index 01f3428..e8904de 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,7 @@ 3.13.0 3.6.3 3.2.5 + 0.8.12 4.8.5 4.8.5.0 1.12.0 @@ -175,6 +176,12 @@ spotless-maven-plugin ${spotless.version} + + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + @@ -197,13 +204,20 @@ org.apache.maven.plugins maven-surefire-plugin + + @{argLine} + + 2 ${skipUTs} org.jboss.logmanager.LogManager ${maven.home} @@ -214,6 +228,11 @@ org.apache.maven.plugins maven-failsafe-plugin + + @{argLine} ${skipTests} ${skipITs} @@ -248,6 +267,88 @@ + + + org.jacoco + jacoco-maven-plugin + + + default-prepare-agent + + prepare-agent + + + ${project.basedir}/target/jacoco-unit.exec + + + + default-prepare-agent-integration + + prepare-agent-integration + + + ${project.basedir}/target/jacoco-integration.exec + true + + + + default-report + post-integration-test + + merge + report + + + + ${project.basedir}/target/jacoco.exec + + + ${project.basedir}/target/ + + jacoco-*.exec + + + + + ${project.basedir}/target/jacoco.exec + + + + default-report-integration + + report-integration + + + ${project.basedir}/target/jacoco.exec + + + + default-check + + check + + + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + 0.60 + + + + + + + + + ${quarkus.platform.group-id} quarkus-maven-plugin