Walks the tests/testthat directory (by default), finds test files,
and runs document_file on each matching file. All
options from document_file() are available here as pass-through
parameters.
document(
root = "tests/testthat",
pattern = "^[Tt]est.*\\.[rR]$",
recurse = TRUE,
exclude = c("testthat.R"),
section_prefix = "# -",
template = c("simple", "advanced", "custom"),
global_fmt = NULL,
section_fmt = NULL,
encoding = "UTF-8",
backup = TRUE,
write = TRUE,
quiet = FALSE
)A list with components:
files: character vector of processed file paths
results: named list of tests_listing_result objects per file
listing: combined data frame with a file column
backups: character vector of backup paths (for files that were written)
Character. Root directory to search. Default "tests/testthat".
Regular expression used with list.files(..., pattern=) to
select test files. Default matches typical testthat files: "^[Tt]est.*\.[rR]$".
Logical. Whether to search subdirectories recursively. Default TRUE.
Character vector of basenames to exclude (e.g., "testthat.R").
Default c("testthat.R").
Character scalar. Lines starting with this prefix denote
sections and are converted to #' @testsSection. Default "# -".
One of c("simple", "advanced", "custom"). Controls the
default numbering format(s). Default "simple".
Character. Numbering template for the global listing. Uses
placeholders {g}, {s}, {i}, {l}. If NULL,
it is derived from template.
Character. Numbering template for section listings.
If NULL, it is derived from template.
File encoding for reading and writing. Default "UTF-8".
Logical. If TRUE, save a timestamped backup before
overwriting. Default TRUE.
Logical. If TRUE, write changes back to path.
If FALSE, return the would-be modified text without writing. Default TRUE.
Logical. If FALSE (default), prints progress messages.
if (FALSE) {
all_res <- document(
root = "tests/testthat",
template = "advanced",
backup = TRUE,
write = TRUE
)
head(all_res$listing)
}
Run the code above in your browser using DataLab