Quick Start: Generating Idempotent test_that() Listings with Sections

Rafal Urniaz

2025-10-16

Overview

This vignette demonstrates a robust, idempotent workflow for generating a roxygen2-style inventory of all test_that() calls in one test file. The function:

Quick Start

library(testthatdocs)

res <- document_file(
  path = system.file("examples", "tests_sample_before.R", package="testthatdocs"),
  section_prefix = "# -",
  template = "advanced",   # or "simple"
  encoding = "UTF-8",
  backup = TRUE,
  write = TRUE
)

# Summary of tests 
res$listing

# Modified test file 
res$text

```

The result includes: