Learn R Programming

usethis (version 1.5.0)

use_testthat: Create tests

Description

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.

Usage

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

The testing chapter of R Packages.

Examples

Run this code
# NOT RUN {
use_testthat()

use_test()

use_test("something-management")
# }

Run the code above in your browser using DataLab