Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins and JaCoCo with sbt

I have a project in Jenkins that I want to create a JaCoCo code coverage report. If I run jacoco:test then jacoco:report locally it creates the correct files (.exec, .classes and sources) in myproject/target/scala-2.9.1/jacoco so it works.

However when building on jenkins this only creates the classes directory meaning it picks up the code but not the test that cover it so I get 0% code coverage.

Has anyone got jacoco working with sbt in this way?

like image 471
Thomas Mitchell Avatar asked Oct 12 '12 11:10

Thomas Mitchell


People also ask

Does JaCoCo work with Scala?

JaCoCo was originally written for Java and runs on the JVM, but because it's bytecode-based it works for Scala too.

How do I check code coverage with JaCoCo?

To get code coverage reports in a Maven project, we first need to set up the JaCoCo Maven plugin for that project. By integrating the JaCoCo plugin, the results of the code coverage analysis can be reviewed as an HTML report. The current version of the JaCoCo-Maven plugin can be downloaded from the MVN Repository.


1 Answers

I was running into this same issue when trying to start a new Scala project. After trying a number of path configurations, I was able to figure a solution.

The default value for Path to class directories is **/classes. I suspect the issue is that the pattern allows for matching target/scala-X.XX/classes/ and target/scala-X.XX/jacoco/classes/.

Changing the class directory path to target/*/classes allowed the Jenkins plug-in to start reporting the correct coverage information.

like image 85
unholysampler Avatar answered Sep 26 '22 00:09

unholysampler