How to Configure Jacoco code coverage report into Java Play framwork project?

105 Views Asked by At

Can someone please give example of how I can set up jacoco report into play project? MY Plugin.sbt looks like below

resolvers += Resolver.sonatypeRepo("public") // (not entirely sure this line is necessary)
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.3.0")

and this is val playVersion = "2.6.25"

I tried

addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.3.0") 

in plugin.sbt but when trying to run activator jacoco:cover my jacoco folder not creating Can some one please guide me ?

1

There are 1 best solutions below

0
On

Just add addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.4.0") to your plugins.sbt and execute sbt jacoco. After that you should see a HTML report in your path target/scala-2.13/jacoco/report/

You can configure jacoco by you needs e.g. generating a HTML and a XML by adding

jacocoReportSettings := JacocoReportSettings().withFormats(JacocoReportFormats.XML, JacocoReportFormats.HTML)

in your build.sbt.

More information: https://www.scala-sbt.org/sbt-jacoco/