Learn R Programming

FastUtils (version 0.2.1)

initTestthat: Initialize Testthat Files

Description

This function scans all files in the specified R directory based on its name, excluding some based on the patterns provided in the ignore argument, and creates testthat files if they are missing. Useful for when many source code files were created from rapid development and unit testing has yet to be setup.

Usage

initTestthat(
  rDir = "R",
  testDir = file.path("tests", "testthat"),
  .ignore = c("-package.R$", "-class.R$", "^data.R$", "^zzz.R$", "^RcppExports.R$"),
  ignore = NULL
)

Value

No return value, called for side effects.

Arguments

rDir

The directory containing R source files. Default is "R".

testDir

The directory where testthat files should be created. Default is "tests/testthat".

.ignore

A character vector specifying regex patterns of files to ignore. Defaults to common patterns c("-package.R$", "-class.R$", "^data.R$", "^zzz.R$", "^RcppExports.R$")

ignore

A character vector of extra regex patterns of R files to ignore

Examples

Run this code
# \donttest{
try({

initTestthat()
initTestthat(rDir = "src", testDir = "tests")
initTestthat(ignore = c("^foo", "-bar.R$"))

}, silent = TRUE)
# }

Run the code above in your browser using DataLab