[ACCEPTED]-Code Coverage Tools for Scala-code-coverage

Accepted answer
Score: 18

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


Score: 9

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

Score: 9

Undercover is little better.


Score: 8

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

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

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

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

Score: 4

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

Also 6 it integrated with Sonar and published on 5 Maven Central.

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

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

Score: 3

I've put together a SBT plugin called xsbt-coveralls-plugin that 5 uses scct under the hood, but publishes 4 the results to http://coveralls.io.

Disclaimer: I've only just built this plugin yesterday (10th March 2013) so don't expect it to be perfect yet, but do send bugs and feature requests to the github page

Still, it's good if you 3 want to code coverage reports to be publicly 2 visible. Check out an example of the results 1 here

More Related questions