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?
Code Coverage is a metric that measures what percentage of your code has been executed during unit and integration tests. JaCoCo is a great open-source toolkit for code coverage measurements. JaCoCo was originally written for Java and runs on the JVM, but because it's bytecode-based it works for Scala too.
Code coverage tools are available for many programming languages and as part of many popular QA tools. They are integrated with build tools like Ant, Maven, and Gradle, with CI tools like Jenkins, project management tools like Jira, and a host of other tools that make up the software development toolset.
SonarQube and JaCoCo are two tools that we can use together to make it easy to measure code coverage. They also provide an overview of the overall health of the source code by finding code duplications, bugs and other issues in the code. This helps us to know whether our code is production-ready or not.
scoverage is a free Apache licensed code coverage tool for Scala that offers statement and branch coverage. scoverage is available for sbt, Maven, Mill, and Gradle. NOTE: That this repository contains the Scala compiler plugin for Code coverage in Scala 2 and other coverage utilities for generating reports.
SCCT is a compiler plugin which instruments the classes to gather coverage data:
http://mtkopone.github.com/scct/
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With