This function is the low-level workhorse that powers
test_package(). Generally, you should not call this function directly.
In particular, you are responsible for ensuring that the functions to test
are available in the test
env (e.g. via
vignette("special-files") to learn more about the conventions for test,
helper, and setup files that testthat uses, and what you might use each for.
test_dir( path, filter = NULL, reporter = NULL, env = NULL, ..., load_helpers = TRUE, stop_on_failure = TRUE, stop_on_warning = FALSE, wrap = lifecycle::deprecated(), package = NULL, load_package = c("none", "installed", "source") )
A list (invisibly) containing data about the test results.
Path to directory containing tests.
NULL, only tests with file names matching this
regular expression will be executed. Matching is performed on the file
name after it's stripped of
Reporter to use to summarise output. Can be supplied
as a string (e.g. "summary") or as an R6 object
See Reporter for more details and a list of built-in reporters.
Environment in which to execute the tests. Expert use only.
Additional arguments passed to
grepl() to control filtering.
Source helper files before running the tests?
TRUE, throw an error if any tests fail.
TRUE, throw an error if any tests generate
If these tests belong to a package, the name of the package.
Strategy to use for load package code:
"none", the default, doesn't load the package.
library() to load an installed package.
pkgload::load_all() to a source package.
To configure the arguments passed to
load_all(), add this
field in your DESCRIPTION file:
Config/testthat/load-all: list(export_all = FALSE, helpers = FALSE)
Each test is run in a clean environment to keep tests as isolated as possible. For package tests, that environment inherits from the package's namespace environment, so that tests can access internal functions and objects.