R/skip_if_not_installed.R
skip_if_not_installed.RdConditionally stop testing a tinytest test file if a required package is not available or not of a minimum required version
skip_if_not_installed(pkg, minimum_version = NULL, quietly = TRUE)
exit_if_not_installed(pkg, minimum_version = NULL, quietly = TRUE)Name of package to check for
Optional minimum required version of pkg
Attempt to find the package quietly; passed to
requireNamespace()
If called within a tinytest test and pkg is either
not installed or not at least minimum_version, triggers an exit
condition; otherwise, returns one of
A string saying that pkg is not installed
A string saying that pkg is installed, but not
at least minimum_version
NULL invisibly
tinyexpect provides both “skip_” and “exit_”
versions of “stop testing” functions due to the different philosophies
of tinytest and testthat; in testthat, tests
are encapsulated by test_that() to create smaller
testing units within a single test file. As such, if a series of tests need
to be passed over for some reason, it makes sense to “skip” a
test_that() block and move on to the next block
tinytest, however, treats each test file as a testing unit. Each
file in inst/tinytest is equivalent to a testthat
test_that() block; as such, if a series of tests need
to be passed over for some reason, it makes sense to “exit” a test
file and move on to the next file in inst/tinytest
In order to provide compatibility with users transitioning from
testthat to tinytest, and to provide continuity with the
tinytest philosophy, tinyexpect provides both skip_-
and exit_- prefixed “stop testing” functions that work
identically to one another
testthat equivalent:
testthat::skip_if_not_installed()
Other "stop testing" functions:
skip(),
skip_on_bioc(),
skip_on_ci(),
skip_on_covr(),
skip_on_cran(),
skip_on_os()