testthat (version 2.0.1)

skip: Skip a test.

Description

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.

Usage

skip(message)

skip_if_not(condition, message = deparse(substitute(condition)))

skip_if(condition, message = deparse(substitute(condition)))

skip_if_not_installed(pkg, minimum_version = NULL)

skip_on_cran()

skip_on_os(os)

skip_on_travis()

skip_on_appveyor()

skip_on_bioc()

skip_if_translated()

Arguments

message

A message describing why the test was skipped.

condition

Boolean condition to check. skip_if_not() will skip if FALSE, skip_if() will skip if TRUE.

pkg

Name of package to check for

minimum_version

Minimum required version for the package

os

Character vector of system names. Supported values are "windows", "mac", "linux" and "solaris".

Helpers

skip_if_not() works like stopifnot(), generating a message automatically based on the first argument.

skip_on_cran() skips tests on CRAN, using the NOT_CRAN environment variable set by devtools.

skip_on_travis() skips tests on travis by inspecting the TRAVIS environment variable.

skip_on_appveyor() skips tests on appveyor by inspecting the APPVEYOR 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.

Details

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.

Examples

Run this code
# NOT RUN {
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
})
# }

Run the code above in your browser using DataCamp Workspace