Learn R Programming

exampletestr (version 1.3.1)

test-shells: Create test shells.

Description

Usage

make_test_shell_fun(fun, pkg_dir = ".", overwrite = FALSE, e_e = TRUE,
  open = TRUE, document = TRUE)

make_tests_shells_file(r_file_name, pkg_dir = ".", overwrite = FALSE, e_e = TRUE, open = TRUE, document = TRUE)

make_tests_shells_pkg(pkg_dir = ".", overwrite = FALSE, e_e = TRUE, open = FALSE, document = TRUE)

Arguments

fun

The name of the function to make a test shell for.

pkg_dir

The directory of the R project for this package (defaults to current directory). Note that this is the parent directory of R/.

overwrite

Overwrite if the test file you're trying to create already exists?

e_e

Set this to FALSE to prevent anything from being put in the shell of an expect_equal() statement.

open

Open the created test file in your editor after it is created?

document

Run devtools::document() to update package documentation before starting?

r_file_name

The name of the .R file within R/. There's no need to specify the file path (as R/x.R, but you can do this if you want), you can just use x.R for whichever file x it is. You can also omit the .R for convenience, however using the wrong case (e.g. .r when the file actually has the extension .R) will produce an error.

Value

The shell of the test file is written into tests/testthat. It has the same name as the .R file it was created from except it has "test_" tacked onto the front.

Examples

Run this code
# NOT RUN {
devtools::create("tempkg")
setwd("tempkg")
file.copy(system.file("extdata", "detect.R", package = "exampletestr"), "R")
make_test_shell_fun("str_detect()", document = TRUE, open = FALSE)
make_tests_shells_file("detect", document = FALSE, open = FALSE)
make_tests_shells_pkg(overwrite = TRUE, document = FALSE)
setwd("..")
filesstrings::dir.remove("tempkg")

# }

Run the code above in your browser using DataLab