What are the available code coverage tools for Scala?

I have Scala spec tests and a Hudson continuous integration set-up. Is there something I can hook-in to this setup to measure and track code coverage?

share|improve this question

57% accept rate
feedback

5 Answers

Undercover is little better.

share|improve this answer
Thanks - will try it out soon. – arnab Aug 12 '09 at 19:04
feedback

I use jacoco. It does not require compile- or runtime- dependencies, instruments classes on the fly w/o special instrumentation phase.

Also it integrated with Sonar and published on Maven Central.

Here is example: https://github.com/Godin/sonar-experiments/tree/master/jacoco-examples/scala-example

I would like to add better reporting: more detailed branch coverage makrup, excluding of generated classes/methods, and to be handy like ScalaDoc (see SCCT reports for example)

share|improve this answer
feedback

One problem with non-mainstream languages (such as Scala) is that tools are hard to find, because they are hard to build.

This technical paper Branch Coverage for Arbitrary Languages Made Easy (I'm the author) describes how to build test coverage tools for langauges in systematic way to help get around this problem, using a generic tool-building infrastructure.

We've implemented test coverage tools for Java, C#, COBOL, C, C++, PL/SQL, ... this way, including instrumenters, data collection and test coverage display and reporting. It would be straightforward to implement Scala like this.

The solutions posed by other answers produces confusing information from the implementation of Scala ("auto genreated classes"). What developers want to see is coverage data in terms of their code. The approach we use instruments the source code, so the results are stated entirely and only in terms of the source code; even the test coverage viewer shows the source code covered with coverage information.

share|improve this answer
feedback

SCCT is a compiler plugin which instruments the classes to gather coverage data:

http://mtkopone.github.com/scct/

share|improve this answer
feedback

I use Cobertura. However, any Java coverage tool should work just fine. The only catch is that you will end up with a large number of auto-generated classes in your coverage list. This is because while Scala compiles down into very natural JVM bytecode, it is forced to produce an unnaturally large number of classes to accommodate common functional features like lazy evaluation.

share|improve this answer
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.