Skip to content

allr/rcov

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

RCov - Coverage of R code

The main aim of the rcov R package is to provide a tool for measuring different types of code coverage for R code.

Installation

Development of package just started recently and is far away from CRAN release yet.

It can be installed easily with the nifty function of the devtools package from CRAN:

library(devtools)
install_github('allr/rcov')

Or download the sources and build manually. If you're running R on Windows, you need to install Rtools.

Basic Usage

Function is the smallest building block for code coverage measure. To start monitoring function for coverage information, it needs to be decorated first by MonitorCoverage. To see the coverage information call ReportCoverageInfo.

f <- function(x) {
    if (x %% 2 == 0){
        x <- x + 20
    } else {
        x <- 10
    }
    x
}
MonitorCoverage(f)
f(1) 
ReportCoverageInfo()
f(2)
ReportCoverageInfo()

More reporting options

ReportCoveragePercentage reports mean of coverage percentage accross all function that coverage is being monitored for.

ReportMissingStatements returns a list of statements that were not executed for function whose coverage is being monitored.

MonitorCoverage(agrep)
MonitorCoverage(abbreviate)
examples(agrep)
# get mean of coverage percentage
ReportCoveragePercentage()
# list statements that were not covered
ReportMissingStatements()

Alternative R Code Coverage Projects

There are some other projects for R code coverage that I am aware of:

Releases

No releases published

Packages

No packages published

Languages