Returns an overview of all unit tests attached to the model. The result
has a print() method.
Arguments
- object
Stock-and-flow model, object of class
stockflow.- test
Integer vector of test number(s) to display (1-based). Defaults to
NULL(show all tests). Can be combined withlabel(intersection).- label
Character vector of regex patterns for partial, case-insensitive label matching. A test is included if its label matches any pattern. E.g.,
c("non-neg", "beta")returns tests matching either fragment. Can be combined withtest(intersection).- ignore_case
Logical; whether
labelmatching is case-insensitive. DefaultTRUE.
Examples
sfm <- stockflow("SIR") |>
unit_test(expr = all(susceptible >= 0)) |>
unit_test(
label = "recovered increases over time",
expr = all(diff(recovered) >= 0)
)
unit_tests(sfm)
#>
#> ── Stock-and-Flow Unit Tests ───────────────────────────────────────────────────
#> 2 tests • 2/2 active • 0/2 include conditions
#> • 1. susceptible is at least 0 (for all values)
#> `all(susceptible >= 0)`
#> • 2. recovered increases over time
#> `all(diff(recovered) >= 0)`
unit_tests(sfm, test = 1L)
#>
#> ── Stock-and-Flow Unit Tests ───────────────────────────────────────────────────
#> 1 tests • 1/1 active • 0/1 include conditions
#> • 1. susceptible is at least 0 (for all values)
#> `all(susceptible >= 0)`
unit_tests(sfm, label = "increases")
#>
#> ── Stock-and-Flow Unit Tests ───────────────────────────────────────────────────
#> 1 tests • 1/1 active • 0/1 include conditions
#> • 2. recovered increases over time
#> `all(diff(recovered) >= 0)`