Integrating JaCoCo in your Play Scala project

Table of contents
Reading Time: 2 minutes

Its always good to have a fine test coverage in any project. I am working on Play framework & this time i’ve tried to integrate the JaCoCo with my play scala project & it’s cool to have it in my project.

I am going to elaborate a few easy steps to integrate the JaCoCo in Play Scala project.

1. Add the following lines of code in your plugin.sbt file. You’ve to add the plugin dependency to your project’s plugins.sbt.

2. Have this import in your Build.scala file.

3. Add the following line in your Build.scala file.

This line adds the jacoco settings to the variable jacoco_settings.

4. Add these settings in to your Play project in Build.scala file as

parallelExecution in jacoco.Config := false makes sure that the ParallelExexution is false during testing.(Look at Point 7)

Note that we’ve a model class with name Test.scala & a test class DemoTest.scala for now.

5. That’s it. Lets run the JaCoCo with command jacoco:cover

6. You’ll find the html file with name index.html which would give you the full test report. You’ll find this file in this path /target/scala-2.9.1/jacoco/html

This is how your coverage report would look like :


7. You can check whether the parallel execution if false or not as

Get the CodeCoverage here

2 thoughts on “Integrating JaCoCo in your Play Scala project2 min read

Comments are closed.