Blog Author: Vladimir Ivanov

Introduction

Scala Code Coverage Tool (SCCT) is a code coverage tool written in Scala and configured as SBT plugin (while integration with Maven is also possible). As for any large project, test are vital for ESME as they gurantee that application works as expected. SCCT gathers data (after source code instrumentation phase) while tests are being run and generates user-friendly report and statistics related to test coverage of source code.

Installation and configuration

Introducing SCCT support to ESME project is a matter of adding SBT plugin and consists of two steps: mixin project definition file with new trait as well as adding new repo and dependency to plugin definition file. Scala 2.8.1-compatible version of SCCT plugin is used in this article, but version for 2.7 is also available.

Project File

Project definition class for web project EsmeProject should mixin with ScctProject trait:

import reaktor.scct.ScctProject

class EsmeProject(info: ProjectInfo) extends DefaultWebProject(info) with ScctProject

Plugins

SCCT related configuration in plugin definition file is shown below:

class Plugins(info : ProjectInfo) extends PluginDefinition(info) {

...

val scctRepo = "scct-repo" at "http://mtkopone.github.com/scct/maven-repo/"

lazy val scctPlugin = "reaktor" % "sbt-scct-for-2.8" % "0.1-SNAPSHOT"

}

 

 

Running


To collect test coverage data with SBT its neccessary to perform following command in SBT console:

sbt> test-coverage

Report files will be produced in ESME_ROOT/server/target/scala_2.8.1/coverage-report/ directory after all tests have been run. Open index.html file in your browser to see the results*.

Here is a video explaining the test results.

Notes

    • Chrome browser is currently not supported.
    • Also note that SCCT tool is still in beta.

Links

Mikko Koponen is the author of SCCT tool. Here is the project page on github. Here is the SCCT home page.