Skip to content

lintr-bot/covr

 
 

Repository files navigation

Covr

wercker status codecov.io

Track test coverage for your R package and (optionally) upload the results to coveralls or codecov.

Installation

Coveralls

If you are already using Travis-CI add the following to your project's .travis.yml to track your coverage results over time with Coveralls.

r_github_packages:
  - jimhester/covr

after_success:
  - Rscript -e 'library(covr);coveralls()'

To use a different CI service, you need to specify your secret repo token for the repository, found at the bottom of your repository's page on Coveralls. Your after_success would then look like this:

after_success:
  - Rscript -e 'library(covr);coveralls(repo_token = "your_secret_token")'

If you are using the secret repo token it is wise to use a Secure Variable so that it cannot be used maliciously.

Also you will need to turn on coveralls for your project at https://coveralls.io/repos/new.

Codecov

Alternatively you can track your coverage results using Codecov, which supports a large number of CI systems out of the box

It also supports uploading coverage results directly from your computer.

For all of the cases include the following in your build script.

library(covr);codecov()

Usage

Iterative usage of covr.

Shiny App

A shiny application can also be used to view coverage per line.

cov <- package_coverage()

shine(cov)

REPL

# if your working directory is in the packages base directory
package_coverage()

# or a package in another directory
package_coverage("lintr")

# zero_coverage() can be used to see only uncovered lines.
zero_coverage(package_coverage())

Implementation

covr tracks test coverage by augmenting a packages function definitions with counting calls.

The vignette vignettes/how_it_works.Rmd contains a detailed explanation of the technique and the rational behind it.

You can view the vignette from within R using

vignette("how_it_works", package = "covr")

Compatibility

Test

Covr is compatible with any testing package, it simply executes the code in tests/ on your package.

Compiler

If your package has compiled code covr requires a compiler that generates Gcov compatible output. It is known to work with clang versions 3.5 and gcc versions 4.2. It should also work with later versions of both those compilers.

It does not work with icc, Intel's compiler.

Alternative Coverage Tools

About

Test coverage reports for R

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 96.3%
  • C 1.4%
  • CSS 1.3%
  • Other 1.0%