Skip to content

ahaid/sbt-scoverage

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sbt-scoverage

sbt-scoverage is a plugin for SBT that integrates the scoverage code coverage library. Find out more about scoverage.

Join the scoverage google group for help, bug reports, feature requests, and general discussion on scoverage.

Build Status

How to use

Add the plugin to your build with the following in project/build.sbt:

resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("org.scoverage" %% "sbt-scoverage" % "0.98.2")

Add the plugin settings to your project somewhere in build.sbt:

ScoverageSbtPlugin.instrumentSettings

Then run the your tests with coverage enabled by entering:

$ sbt clean scoverage:test

After the tests have finished you should find the coverage reports inside target/scoverage-report.

If you want to see a project that is already setup to use scoverage in both sbt and maven, then clone the scoverage samples project.

Exclude classes and packages

You can exclude classes from being considered for coverage measurement by providing semicolon-separated list of regular expressions.

Example:

ScoverageSbtPlugin.ScoverageKeys.excludedPackages in ScoverageSbtPlugin.scoverage :=
  "<empty>;Reverse.*;.*AuthService.*;models\.data\..*"

The regular expressions are matched against the fully qualified class name, and must match the entire string to take effect.

Any matched classes will not be instrumented or included in the coverage report.

You can also mark sections of code with comments like:

  // $COVERAGE-OFF$
  ...
  // $COVERAGE-ON$

Any code between two such comments will not be instrumented or included in the coverage report.

Disable parallel test execution

It is possible to disable the parallel execution for tests:

parallelExecution in ScoverageSbtPlugin.scoverageTest := false,

Coveralls

If you have an open source project then you can add code coverage metrics with the excellent website http://coveralls.io. Scoverage will integrate with coveralls using the sbt-coveralls plugin.

Plugin for SonarQube

If you want to visually browse statement coverage reports then use this plugin for SonarQube. It allows you to review overall project statement coverage as well as dig deeper into sub-modules, directories and source code files to see uncovered statements. Statement coverage measurement can become an integral part of your team's continuous integration process and a required quality standard.

License

This software is licensed under the Apache 2 license, quoted below.

Copyright 2013 Stephen Samuel

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

About

SBT plugin for scoverage

Resources

Stars

Watchers

Forks

Packages

No packages published