In my last blog i’ve elaborated the steps to integrate the JaCoCo with your Play Scala project. This time we’ll learn about how to integrate the Scala Code Coverage Tool ( SCCT ) in your Play Scala project.
Just some easy steps and you’re done with SCCT integration. Lets see it in action.
1. Add the following resolvers in your plugin.sbt file.
resolvers += Classpaths.typesafeResolver resolvers += "scct-github-repository" at "http://mtkopone.github.com/scct/maven-repo"
2. Add this sbt plugin there as well.
addSbtPlugin("reaktor" % "sbt-scct" % "0.2-SNAPSHOT")
3 . Define a lazy val for SCCT settings in your Build.scala & include the settings as below :
lazy val scct_settings = Defaults.defaultSettings ++ Seq(ScctPlugin.instrumentSettings: _*) ................ ................ val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA,settings = scct_settings).settings( testOptions in Test := Nil )
4. We have a model object Hello.scala in app/models & its corresponding test HelloTest.scala in test/models
5. After adding these just do :
play clean compile eclipsify run
6. Now its time to have the coverage report for our tests. Run scct:test as shown below
7. You’d find the test coverage report for you project in /target/scala-2.9.1/coverage-report/index.html .
Note : Open the index.html file with Firefox browser.
8. Here’s our test coverage report :
Find the code here on Github