Create a subdir in tests/testthat/
and optionally an R script
containing a helper function to run all tests in that subdir. Useful for
separating long-running tests from your unit tests, or storing tests that
you do not want to run on CRAN or during R CMD Check. For running tests in
tests/testthat/
subdirectories see test_subdir()
.
use_test_subdir(path, make_tester = TRUE, ignore_tester = TRUE) use_integration_tests() use_acceptance_tests() use_manual_tests()
path |
|
---|---|
make_tester |
|
ignore_tester |
|
TRUE
on success (invisibly).
Three preset test subdirs are defined at the moment:
test_integration()
Integration tests, also called component tests.
Put tests here that test if several functions / parts of your program
work together as expected. You can create the relevant subdir
testthat/integration_tests/
with use_integration_tests()
.
test_acceptance()
Acceptance tests. This is the highest levels of
tests. Put tests here that verifies if your package fulfills the
goals/requirements you set out to achieve with your package were met.
You can create the relevant subdir testthat/acceptance_tests/
with use_acceptance_tests()
.
test_manual()
Manual tests. Put tests here that produce output
that has to be manually verified, such as: console output, pdf files,
plots. It is recommended you collect the output files of such tests in
tests/testthat/testout
. You can create the relevant subdir
with testthat/manual_tests/
with use_manual_tests()
.
You can modify the default paths for manual, acceptance and integration tests
by setting the respective options()
, but it is recommended to create your
own test subdirs instead.
Other infrastructure:
use_testdata()
,
use_tester()
if (FALSE) { use_test_subdir("special_tests", make_tester = TRUE) ## Reload the Package manually... ## Create some tests in tests/testthat/test_special_tests/ test_special_tests() }