mvn spring-boot:run
Run simple tests:
mvn clean test
An updated report will be generated in the folder:
/target/site/jacoco/index.html
To check if coverage level is under minimum expected (see pom.xml
for details):
mvn clean verify
Pay attention to slight different value of code coverage, according the way it was invoked. For example:
- with
mvn clean verify
there is 98% (missed 2 of 114 instructions) - with Intellij's Run with Coverage there is 94% (missed 6 of 118 instructions)
To cover Spring code properly pay attention to pom.xml entry:
<execution>
<id>default-report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
- StackOverflow: Generate Code Coverage with JaCoCo and spring-boot-maven-plugin
- Project: https://github.com/maciejwalkowiak/jacoco-spring-boot-maven-plugin-sample
For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Spring Configuration Processor
- Spring Boot DevTools
- Spring Web
- Prometheus
The following guides illustrate how to use some features concretely: