Skip to contents

Create a validation requirement, test case, or test code file

Usage

vt_use_test_case(
  name,
  username = vt_username(),
  title = NULL,
  open = interactive(),
  add_before = NULL,
  add_after = NULL
)

vt_use_test_code(
  name,
  username = vt_username(),
  open = interactive(),
  add_before = NULL,
  add_after = NULL
)

vt_use_req(
  name,
  username = vt_username(),
  title = NULL,
  open = interactive(),
  add_before = NULL,
  add_after = NULL
)

Arguments

name

The name/path of the validation item. These can be named with your file system separator and will be organized as a directory structure. Items are located at ./inst/validation/<ItemType>/{name}.

username

The username to insert into the validation item as the author.

title

Title for the requirement defaults to be the base name passed sans file paths or extensions.

open

Should the newly made file be opened for editing.

add_before, add_after

If either parameters is supplied, the location to add the validation item to the validation configuration. If no parameter is passed the item is added at the end.

Value

Path to the newly created validation item file, invisibly.

Examples

withr::with_tempdir({
vt_create_package("example.package")
setwd("example.package")
vt_add_user_to_config(
  username = whoami::username(),
  name = "Sample Name",
  title = "Sample",
  role = "example"
 )
# Create req at the cases top level `inst/validation/cases/case1`
vt_use_test_case("case1", open = FALSE)

# Create req at `inst/validation/cases/regTests/Update2/case2`
vt_use_test_case("regTests/Update2/case2", open = FALSE, add_before = "case1.md")

# Create a test case using tidy select
vt_use_test_case("case1a", open = FALSE, add_after = tidyselect::starts_with("case1"))

})
#>  Creating 'example.package/'
#>  Setting active project to '/tmp/Rtmp7SIDTD/file19841f880cf5/example.package'
#>  Creating 'R/'
#>  Writing 'DESCRIPTION'
#> Package: example.package
#> Title: What the Package Does (One Line, Title Case)
#> Version: 0.0.0.9000
#> Authors@R (parsed):
#>     * First Last <first.last@example.com> [aut, cre] (YOUR-ORCID-ID)
#> Description: What the package does (one paragraph).
#> License: `use_mit_license()`, `use_gpl3_license()` or friends to
#>     pick a license
#> Encoding: UTF-8
#> Roxygen: list(markdown = TRUE)
#> RoxygenNote: 7.3.1
#>  Writing 'NAMESPACE'
#>  Setting active project to '<no active project>'
#> Created package structure
#>  Adding '!*' to 'example.package/vignettes/validation/.gitignore'
#> Created vignettes/validation  in package structure
#> validation config file created. Add user information through `vt_add_user_to_config()`
#> User `runner` added to validation config file.
#> Item created:test_cases/case1.md 
#> Filename(s): case1.md added to validation config file.
#> Item created:test_cases/regTests/Update2/case2.md 
#> Filename(s): regTests/Update2/case2.md added to validation config file.
#> Item created:test_cases/case1a.md 
#> Filename(s): case1a.md added to validation config file.