Code Coverage Tools for Scala

What are the available code coverage tools for Scala?

I have Scala tests and setting up Hudson continuous integration. Is there anything I can connect to this setting to measure and track code coverage?

+43
scala unit-testing continuous-integration hudson code-coverage
Jun 05 '09 at 2:15
source share
6 answers

SCCT is a compiler plugin that allows classes to collect coverage data:

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

+18
Oct 11 '10 at
source share

I am using Cobertura . However, any Java coverage tool should work fine. The only catch is that you get a large number of automatically generated classes in your coverage list. This is because while Scala compiles into the very natural JVM bytecode, it is forced to create an unnaturally large number of classes to accommodate common functional functions such as lazy evaluation.

+9
Jun 05 '09 at 7:01
source share

Undercover is a little better.

+9
Aug 07 '09 at 10:29
source share

One problem with non-core languages ​​(e.g. Scala) is that tools are hard to find because they are hard to build.

This technical article, Industry Coverage for Custom Languages ​​Made Easy (I am the author), describes how to systematically create test coverage tools for language diagrams to help circumvent this problem using a common tool creation infrastructure.

We have implemented object coverage tools for Java, C #, COBOL, C, C ++, PL / SQL, ... in this way, including tools, data collection, and displaying test coverage and reporting. It would be easy to implement Scala like this.

Solutions created by other answers create confusing information from a Scala implementation ("auto-developed classes"). What developers want to see is coverage data in terms of their code. The approach we use uses the source code, so the results are completely and only from the point of view of the source code; even a test coverage viewer shows source code covered in coverage information.

+8
Mar 02 '11 at 23:00
source share

I have compiled an SBT plugin called xsbt-coveralls-plugin which uses scct under the hood but publishes the results of http://coveralls.io .

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

However, it’s good if you want coverage reports to be publicly available. See sample results here

+3
Mar 11 '13 at 13:47
source share

I am using jacoco. It does not require compilation or runtime, tool classes on the fly without a special hardware phase.

It is also integrated with Sonar and published on Maven Central.

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

I would like to add better reporting: a more detailed distribution of the coverage of makrup branches, the exception of generated classes / methods and be convenient, for example, ScalaDoc (see, for example, SCCT reports)

+2
Nov 11 2018-11-11T00:
source share



All Articles