This is a simple wrapper for devtools::test(), but rather than running the tests in inst/tests/ or tests/testthat/, it runs the tests in a subdirectory of that folder. For creating such subdirectories, please also see use_test_subdir().

test_subdir(subdir, ...)







character scalar. subdir of inst/tests/ or tests/testthat that contains the tests


passed on to devtools::test()


A testthat::testthat_results object (invisibly)

Test subdirectory presets

Three preset test subdirs are defined at the moment:


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().


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().


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.

See also