test_module_library {BioCro} | R Documentation |
Run module test cases for an entire BioCro module library
Description
Modules can be tested using test cases, which are sets of known outputs that
correspond to particular inputs. The test_module_library
function
provides a way to run all test cases for all modules in a BioCro module
library.
Usage
test_module_library(library_name, directory, modules_to_skip = c())
Arguments
library_name |
The name of a BioCro module library. |
directory |
The directory where module test case files are stored, e.g.
|
modules_to_skip |
A vector of local module name strings indicating any modules from the library that should not be tested. This feature should be used sparingly, since there are very few legitimate reasons to skip a module test. |
Details
For each module in the specified library, test_module_library
loads
stored test cases from the specified directory and runs each test case,
storing information about any test failures or other issues that may occur.
If any problems are detected, test_module_library
throws an error with
a message describing the issues.
For an example of how this function can be used along with the
testthat
package, see
tests/testthat/test.Modules.R
.
Value
None
See Also
Examples
# Here we will initialize a module test case file in a temporary directory, and
# then use `test_module_library` to test it. We will need to skip most of the
# modules in the library, since we only have a test case for one of them.
td <- tempdir()
initialize_csv(
'BioCro:thermal_time_linear',
td,
nonstandard_inputs = list(temp = -1),
overwrite = TRUE
)
# Get a list of local module names, excluding the module that has a test case
all_modules <- get_all_modules('BioCro')
skip <- all_modules[all_modules != 'BioCro:thermal_time_linear']
skip <- gsub('BioCro:', '', skip)
test_module_library('BioCro', td, skip)
# If we attempt to test the entire library, we will get errors since only one
# module actually has an associated case file
tryCatch(
{
test_module_library('BioCro', td)
},
error = function(e) {print(e)}
)