Java Code Coverage (JaCoCo) is a well-known tool for measuring test coverage.
To use it in our project, we need to add a few lines to our Gradle configuration file, that is, build.gradle:
- Add the Gradle plugin for JaCoCo:
apply plugin: 'jacoco'
- To see the JaCoCo results, run the following from your command prompt:
gradle test jacocoTestReport
- The same Gradle tasks can be run from the Gradle Tasks IDEA Tool Window.
- The end result is stored in the build/reports/jacoco/test/html directory. It's an HTML file that can be opened in any browser:
Further chapters of this book will explore code coverage in more detail. Until then, go to http://www.eclemma.org/jacoco/ for more information.