skip: Skip a test.

Description Usage Arguments Details Helpers Examples

View source: R/skip.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

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

host

A string with a hostname to lookup

os

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

msgid

R message identifier used to check for translation: the default uses a message included in most translation packs. See the complete list in R-base.pot.

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.

Helpers

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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
})

Example output



testthat documentation built on Dec. 1, 2019, 5:06 p.m.