Learn R Programming

testthat (version 3.1.9)

is_testing: Determine testing status

Description

These functions help you determine if you code is running in a particular testing content:

  • is_testing() is TRUE when run inside a test.

  • is_parallel() is TRUE if the test is run in parallel.

  • is_checking() is TRUE when the tests run as part of R CMD check (i.e. by test_check()).

  • testing_package() gives name of the package being tested.

A common use of these functions is to compute a default value for a quiet argument with is_testing() && !is_snapshotting(). In this case, you'll want to avoid an run-time dependency on testthat, in which case you should just copy the implementation of these functions in a utils.R or similar.

Usage

is_testing()

is_parallel()

is_checking()

is_snapshot()

testing_package()

Arguments