Scaffolds CRAN-compliant `testthat` boilerplate for a specific function by interactively prompting the user about expected behaviors, output types, and edge cases.
Value
Invisibly returns a named list with components: status ("done",
"cancelled", or "error"), function_name, test_file,
and output_type.
Details
The function automates the creation of a test file in the `tests/testthat/` directory:
Verifies that the `tests/testthat` directory exists (suggesting `usethis::use_testthat()` if it does not).
Prompts for the name of the function to be tested and creates a corresponding `test-functionname.R` file.
Interactively determines the expected output type (e.g., data frame, list, numeric) to generate appropriate `expect_*` calls.
Asks whether to include tests for output dimensions or error handling for invalid inputs.
Writes a structured boilerplate file containing `test_that` blocks with TODO comments for the user to fill in mock data.
Warning
This function modifies files on disk or the global environment. Please ensure you have a backup or are using version control (e.g., Git) before execution.
Examples
if (interactive()) {
scaffold_tests()
}
