source_file {testthat} | R Documentation |
These are used by test_dir()
and friends
source_file(path, env = test_env(), chdir = TRUE, encoding = "unknown", wrap = TRUE) source_dir(path, pattern = "\\.[rR]$", env = test_env(), chdir = TRUE, wrap = TRUE) source_test_helpers(path = "tests/testthat", env = test_env()) source_test_setup(path = "tests/testthat", env = test_env()) source_test_teardown(path = "tests/testthat", env = test_env())
path |
Path to files. |
env |
Environment in which to evaluate code. |
chdir |
Change working directory to |
encoding |
Deprecated. |
wrap |
Automatically wrap all code within |
pattern |
Regular expression used to filter files. |
For package code, tests should live in tests/testthat
.
There are four classes of .R
files that have special behaviour:
Test files start with test
and are executed in alphabetical order.
Helper files start with helper
and are executed before tests are
run and from devtools::load_all()
.
Setup files start with setup
and are executed before tests, but not
during devtools::load_all()
.
Teardown files start with teardown
and are executed after the tests
are run.