These functions help you determine if you code is running in a particular testing context:
is_testing()
isTRUE
inside a test.is_snapshot()
isTRUE
inside a snapshot testis_checking()
isTRUE
inside ofR CMD check
(i.e. bytest_check()
).is_parallel()
isTRUE
if the tests are run in parallel.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_snapshot()
. 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 into a utils.R
or similar.