skip: Skip a test

Description Usage Arguments Helpers Examples

View source: R/skip.R

Description

skip_if() and skip_if_not() allow you to skip tests, immediately concluding a test_that() block without executing any further expectations. This allows you to skip a test without failure, if for some reason it can't be run (e.g. it depends on the feature of a specific operating system, or it requires a specific version of a package).

See vignette("skipping") for more details.

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 one or more operating systems to skip on. Supported values are "windows", "mac", "linux", and "solaris".

arch

Character vector of one or more architectures to skip on. Common values include "i386" (32 bit), "x86_64" (64 bit), and "aarch64" (M1 mac). Supplying arch makes the test stricter; i.e. both os and arch must match in order for the test to be skipped.

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.

Helpers

Examples

1
2
3
4
5
6
7
8
if (FALSE) skip("No internet connection")

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

── Skip (???): skip example ────────────────────────────────────────────────────
Reason: skip

testthat documentation built on Oct. 4, 2021, 9:07 a.m.