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

Arguments

path

character scalar. Will be processed with base::make.names() to make a syntactically valid name.

make_tester

logical or character scalar. Create an R script with a test helper function. If TRUE an R script file will be placed into the R/ directory of the current package, containing a function definition for running the tests in path. The file will be named testthis-testers.R, but you can specify your own name by passing a character scalar to make_tester(). See use_tester() for details.

ignore_tester

logical scalar`. Add tester file to .Rbuildignore?

Value

TRUE on success (invisibly).

Test subdirectory presets

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.

See also

test_subdir()

Other infrastructure: use_testdata(), use_tester()

Examples

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