Alessandro
Alessandro

Reputation: 369

How to configure jacoco4sbt with Play Framework 2.3

I decided to use jacoco4sbt as our Java code coverage tool for our Play 2.3 project. I followed the instructions from jacoco4sbt but for some reason some of the tests fail when I execute activator jacoco:coverage and no coverage report gets generated. All unit tests pass when I run activator test. In my build.sbt file I have

jacoco.settings parallelExecution in jacoco.Config := false libraryDependencies ++= Seq( javaJdbc, javaEbean, cache, javaWs, "com.google.inject" % "guice" % "3.0", "com.github.fge" % "json-schema-validator" % "2.1.7", "org.openl" % "org.openl.core" % "5.13.2", "org.openl.rules" % "org.openl.rules" % "5.13.2")

However, when I run jacoco:parallelExecution it still says true. In my plugins.sbt file I have added addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")

When I'm in activator and I run jacoco:report I get the following error (jacoco:report) java.io.FileNotFoundException: C:\users\me\project\target\scala-2.11\jacoco\jacoco.exec (The system cannot find the file specified)

When I run an about I get

[info] This is sbt 0.13.5 
[info] The current project is {file:/C:/Users/me/project/}root 20 15.03.10.04.21.a5de5e0  
[info] The current project is built against Scala 2.11.4 
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, play.Play, play.PlayJava, play .PlayScala, play.twirl.sbt.SbtTwirl, com.typesafe.sbt.jse.SbtJsEngine, com.types afe.sbt.jse.SbtJsTask, com.typesafe.sbt.web.SbtWeb, com.typesafe.sbt.webdriver.S btWebDriver, com.typesafe.sbt.SbtEcho, org.sbtidea.SbtIdeaPlugin, com.typesafe.sbteclipse.plugin.EclipsePlugin, com.typesafe.sbt.SbtNativePackager, com.typesafe .sbt.SbtGit, de.johoop.jacoco4sbt.JacocoPlugin 
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4

Do I need to have a specific jacoco config file, and if so where? I notice that executing jacoco:test runs the tests successfully. Afterwards when I run jacoco:report, I get that same file not found error I mentioned.

Upvotes: 1

Views: 1718

Answers (1)

Alessandro
Alessandro

Reputation: 369

The jacoco.exec file was not being generated because I had a failing test. In order for the code coverage report to be generated, you must not have any failing tests. After I realized that and fixed the test, I was able to generate the report.

Upvotes: 3

Related Questions