First public release
This is the first public release of sbt-coverage: an sbt code coverage
processor which uses the undercover
code coverage tool.
Please note that this tool relies on functionality added in sbt version
0.7.5.RC0. To upgrade your project to use this version, run sbt and enter:
> set sbt.version 0.7.5.RC0
...
> reload
...
To get started, start up sbt and enter the following commands at the sbt
prompt:
> *undercoverRepo at http://undercover.googlecode.com/svn/maven/repository/
...
> *coverage is com.proinnovate sbt-coverage 0.1
This tells sbt where to find the undercover library and then loads the
sbt-coverage processor and calls it coverage. From now onwards you should
be able to run coverage within any sbt project on your machine. In other
words, because it is an sbt processor (rather than a plugin) you do not need
to install it into each project or make any changes to the configuration of
the project.
So, if you now enter:
This should run all your unit tests and produce a report that looks a bit like
this and also drills down to listings of your source code with each line
highlighted and with frequency counts on each line.
Why use a code coverage tool
The code coverage tool instruments the class files of your Java and Scala code
causing them to record which parts of the code are used when you run your
unit tests. The report provides a top level report of which parts of your
code where touched by the tests right down to listings of all your source with
lines highlighted to indicate which lines were used and how many times they
were used.
If you are trying to optimise your code the information on the number of times
lines of your code are called can be one helpful input into the performance
optimisation mix. The general readability of these reports and the quick and
easy way of producing them makes this particularly attractive.
Limitations
Currently the code coverage is only carried out on the unit tests not on
running the code. Also, at present, the undercover code coverage tool makes
no special provision for Scala code so the reports tend to be overloaded with
references to the many classes the Scala compiler generates from your code.
I hope to offer some patches soon to tidy this up a bit.
Feedback
I encourage feedback of all kinds so please mail me: stuart dot roebuck @
proinnovate dot com. Or tweet me at stuey.
sbt-coverage is an
sbt (simple-build-tool) processor
which simplifies the generation of code coverage reports of Scala / Java
project unit tests using the undercover
code coverage tool.
This software is Copyright © 2011, Stuart Roebuck and licensed under a
standard MIT license (more specifically referred to as the Expat license). See
the LICENSE.md file for details.