# Example 1: Defining an individual test case for the 'BioCro' module library's
# 'thermal_time_linear' module and running the test. This test will pass, so the
# return value will be an empty string: `character(0)`
test_module(
'BioCro:thermal_time_linear',
case(
list(fractional_doy = 101, sowing_fractional_doy = 100, tbase = 20, temp = 44),
list(TTc = 1.0),
'temp above tbase'
)
)
# Example 2: Defining an individual test case for the 'BioCro' module library's
# 'thermal_time_linear' module and running the test. This test will fail, so the
# return value will be a message indicating the failure. Because verbose is TRUE
# by default, information about the failure will also be printed.
test_module(
'BioCro:thermal_time_linear',
case(
list(fractional_doy = 101, sowing_fractional_doy = 100, tbase = 20, temp = 44),
list(TTc = 2.0),
'temp above tbase'
)
)
# Example 3: Loading a set of test cases from a file and running one of them.
# Note: here we use the `initialize_csv` function first to ensure that there is
# a properly defined test file in a temporary directory.
td <- tempdir()
module_name <- 'BioCro:thermal_time_linear'
initialize_csv(module_name, td)
cases <- cases_from_csv(module_name, td)
test_module(module_name, cases[[1]])
Run the code above in your browser using DataLab