make-test-shells {exampletestr}R Documentation

Create test shells.

Description

Usage

make_test_shell_fun(
  fun,
  pkg_dir = ".",
  overwrite = FALSE,
  e_e = TRUE,
  roxytest = FALSE,
  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 a testthat::expect_equal() statement.

roxytest

Copy roxytest package ⁠@testexamples⁠ code to clipboard instead of creating file in tests/testthat?

open

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

document

Run roxygen2::roxygenize() 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

## Not run: 
pkg_dir <- "~/mylilpkg"
usethis::create_package(pkg_dir, rstudio = FALSE, open = FALSE)
fs::file_copy(
  system.file("extdata", c("detect.R", "match.R"),
    package = "exampletestr"
  ),
  paste0(pkg_dir, "/R")
)
make_test_shell_fun("str_detect()", pkg_dir,
  document = TRUE, roxytest = TRUE
)
make_test_shell_fun("str_detect()", pkg_dir,
  document = TRUE, open = FALSE
)
make_tests_shells_file("detect", pkg_dir,
  document = FALSE, open = FALSE
)
make_tests_shells_pkg(pkg_dir,
  overwrite = TRUE, document = FALSE
)
fs::dir_delete(pkg_dir)

## End(Not run)


[Package exampletestr version 1.7.1 Index]