There are two helper functions:

  • use_testthat() sets up overall testing infrastructure: creates tests/testthat/, tests/testthat.R, and adds testthat to Suggests.

  • use_test() sets up individual test files: creates tests/testthat/test-<name>.R and, optionally, opens it for editing.

use_testthat()

use_test(name = NULL, open = interactive())

Arguments

name

Base of test file name. If NULL, and you're using RStudio, will be based on the name of the file open in the source editor.

open

Open the newly created file for editing? Happens in RStudio, if applicable, or via utils::file.edit() otherwise.

See also

Examples

# NOT RUN {
use_testthat()

use_test()

use_test("something-management")
# }