Learn R Programming

SpaDES (version 1.1.0)

moduleCoverage: Calculate module coverage of unit tests

Description

Calculate the test coverage by unit tests for the module and its functions.

Usage

moduleCoverage(name, path)

## S3 method for class 'character,character': moduleCoverage(name, path)

## S3 method for class 'character,missing': moduleCoverage(name)

Arguments

name
Character string. The module's name.
path
Character string. The path to the module directory (default is the current working directory).

Value

  • Return two coverage objects: moduleCoverage and functionCoverage. The moduleCoverage contains percentage of coverage by unit tests for the module. The functioinCoverage contains percentages of coverage by unit tests for functions in the module. The returned two objects are compatible to shine function in covr package. Please use shine to view the information of coverage.

See Also

newModule.

Examples

Run this code
library(magrittr)
 library(SpaDES)
 tmpdir <- tempdir()
 modulePath <- file.path(tmpdir, "Modules") %>% checkPath(create = TRUE)
 moduleName <- "forestAge" # sample module to test
 downloadModule(name = moduleName, path = modulePath) # download sample module
 testResults <- moduleCoverage(name = moduleName, path = modulePath)
 shine(testResults$moduleCoverage)
 shine(testResults$functionCoverage)
 unlink(tmpdir, recursive = TRUE)

Run the code above in your browser using DataLab