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

moduleCoverage(mod, modulePath = "..")

Arguments

mod

Character string. The module's name. Default is basename(getwd())

modulePath

Character string. The path to the module directory (default is "..", i.e., one level up from working directory).

Value

Return a list of two coverage objects and two data.table objects. The two coverage objects are named moduleCoverage and functionCoverage. The moduleCoverage object contains the percent value of unit test coverage for the module. The functionCoverage object contains percentage values for unit test coverage for each function defined in the module. Please use report to view the coverage information. Two data.tables give the information of all the tested and untested functions in the module.

Note

When running this function, the test files must be strictly placed in the tests/testthat/ directory under module path. To automatically generate this folder, please set unitTests = TRUE when creating a new module using newModule. To accurately test your module, the test filename must follow the format test-functionName.R.

See also

Author

Yong Luo

Examples

if (FALSE) { tmpdir <- file.path(tempdir(), "coverage") 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) report(testResults$moduleCoverage) report(testResults$functionCoverage) unlink(tmpdir, recursive = TRUE) mc1 <- moduleCoverage("Biomass_core", modulePath = "..") }