Generate testthat Style Test .R Files

Usage

new_test(fun, path = "tests/testthat", file.name = NULL)

Arguments

fun
A function or character string naming the function.
path
Path to directory to generate the function test in. Default is to use "tests/testthat" for ease of use within RStudio.
file.name
By default the file is named the same as: "text-" + fun + ".R". This can be changed by supplying a file name to file.name.

Generate <span class = "pkg">testthat</span> Style Test .R Files

Generate <span class = "pkg">testthat</span> Style Test .R Files

Value

Generates a ‘test-____.R’ file.

Description

Quickly produce a testthat style test ‘.R’ template file from a function (output file will include the function) or a character string.

Examples

dir.create("temp_dir") new_test(paste, "temp_dir")
test file created: temp_dir/test-paste.R
new_test("myfun", "temp_dir")
test file created: temp_dir/test-myfun.R
unlink("temp_dir", TRUE, TRUE)