r-lib/covr
Test coverage reports for R
Featured achievements
The project's latest awards
#1 Repository of the day
#1 Repository of the day
#1 Repository of the day
📊 Test coverage reports for R packages, right where you work
Track what your R tests actually hit — locally, in RStudio, or in CI.
covr, from the r-lib team, measures test coverage for R packages. Run it locally to inspect coverage line by line, or upload results to codecov or coveralls. Install from CRAN with install.packages("covr"), and set up GitHub Actions coverage quickly with usethis::use_github_action("test-coverage").
✨ Highlights
- Local coverage reports: Call
report()to inspect coverage for each line in your package (requires the DT package). - RStudio Addin: Run
report()on the active project from the Addin menu or bind it to a shortcut (e.g., Ctrl-Shift-C). - Interactive API: Use
package_coverage()(current directory or another path), view results withas.data.frame(cov), and find gaps withzero_coverage(cov)(opens a marker pane in RStudio). - File and directory exclusions: Add a
.covrignorefile in the package root (glob rules viaSys.glob()); location can be set viaCOVR_COVRIGNOREor thecovr.covrignoreoption. - Function and line exclusions: Exclude by name with
function_exclusions(regex), or by file/ranges withline_exclusions. - In-source exclusion comments: Mark lines with
# nocov, or ranges with# nocov start/# nocov end(patterns configurable viacovr.exclude_pattern,covr.exclude_start,covr.exclude_end). - Works with common test frameworks: Compatible with any testing package; covr uses
tools::testInstalledPackage()to run package tests. - Compiled code support: Supports Intel's
icc, clang3.5+, and gcc4.2+; configurecovr.gcov(set to""to turn off compiled-code coverage).
💡 Why it matters
Coverage is most useful when it fits into everyday development, not just CI. covr makes that practical for R packages: generate an interactive report, jump to uncovered lines with zero_coverage(), and keep noisy or intentional gaps out of the numbers using .covrignore, targeted exclusions, or # nocov comments.
Under the hood, covr tracks coverage by modifying a package's code to add tracking calls to each call (see the vignettes/how_it_works.Rmd vignette). The README notes it is not intended to run during R CMD check, since code modification and compiling without optimization for compiled-code coverage can affect behavior.
#R #TestCoverage #Codecov #OpenSource #TiniX
Similar Projects
Discover other similar projects and AI models.
Code coverage tool for compiled programs, Python and Bash which uses debugging information to collect and report data without special compilation options
Code coverage for Ruby with a powerful configuration library and automatic merging of coverage across test suites
Node command tool to generate TypeScript coverage report
iOS project template with fastlane lanes, Travis CI jobs and GitHub integrations of Codecov, HoundCI for SwiftLint and Danger
Take Julia code coverage and memory allocation results, do useful things with them