This function allows you to skip a test if it's not currently available. This will produce an informative message, but will not cause the test suite to fail.
skip(message) skip_if_not(condition, message = deparse(substitute(condition))) skip_if(condition, message = NULL) skip_if_not_installed(pkg, minimum_version = NULL) skip_if_offline(host = "r-project.org") skip_on_cran() skip_on_os(os) skip_on_travis() skip_on_appveyor() skip_on_ci() skip_on_covr() skip_on_bioc() skip_if_translated(msgid = "'%s' not found")
| message | A message describing why the test was skipped. |
|---|---|
| condition | Boolean condition to check. |
| pkg | Name of package to check for |
| minimum_version | Minimum required version for the package |
| host | A string with a hostname to lookup |
| os | Character vector of system names. Supported values are
|
| msgid | R message identifier used to check for translation: the default
uses a message included in most translation packs. See the complete list in
|
skip* functions are intended for use within test_that()
blocks. All expectations following the skip* statement within the
same test_that block will be skipped. Test summaries that report skip
counts are reporting how many test_that blocks triggered a skip*
statement, not how many expectations were skipped.
skip_if_not() works like stopifnot(), generating
a message automatically based on the first argument.
skip_if_offline() skips tests if an internet connection is not available
using curl::nslookup().
skip_on_cran() skips tests on CRAN, using the NOT_CRAN
environment variable set by devtools.
skip_on_travis() skips tests on Travis CI by inspecting the
TRAVIS environment variable.
skip_on_appveyor() skips tests on AppVeyor by inspecting the
APPVEYOR environment variable.
skip_on_ci() skips tests on continuous integration systems by inspecting
the CI environment variable.
skip_on_covr() skips tests when covr is running by inspecting the
R_COVR environment variable
skip_on_bioc() skips tests on Bioconductor by inspecting the
BBS_HOME environment variable.
skip_if_not_installed() skips a tests if a package is not installed
or cannot be loaded (useful for suggested packages). It loads the package as
a side effect, because the package is likely to be used anyway.
if (FALSE) skip("No internet connection") ## The following are only meaningful when put in test files and ## run with `test_file`, `test_dir`, `test_check`, etc. test_that("skip example", { expect_equal(1, 1L) # this expectation runs skip('skip') expect_equal(1, 2) # this one skipped expect_equal(1, 3) # this one is also skipped })