| test_examples_as_testthat {testex} | R Documentation |
Execute examples from Rd files as testthat tests
Description
Reads examples from Rd files and constructs testthat-style tests.
testthat expectations are built such that
Usage
test_examples_as_testthat(
package,
path,
...,
test_dir = file.path(tempdir(), "testex-tests"),
clean = TRUE,
overwrite = TRUE,
roxygenize = !is_r_cmd_check() && uses_roxygen2(path),
reporter = testthat::get_reporter()
)
Arguments
package |
A package name whose examples should be tested |
path |
Optionally, a path to a source code directory to use. Will only
have an effect if parameter |
... |
Additional argument unused |
test_dir |
An option directory where test files should be written. Defaults to a temporary directory. |
clean |
Whether the |
overwrite |
Whether files should be overwritten if |
roxygenize |
Whether R documentation files should be re-written using
|
reporter |
A |
Details
Each example expression is expected to run without error
Any
testexexpectations are expected to pass
Generally, you won't need to use this function directly. Instead, it
is called by a file generated by use_testex_as_testthat() which will add
any testex example tests to your existing testthat testing suite.
Value
The result of testthat::source_file(), after iterating over
generated test files.
Note
It is assumed that this function is used within a testthat run, when
the necessary packages are already installed and loaded.
Examples
# library(pkg.example)
path <- system.file("pkg.example", package = "testex")
test_examples_as_testthat(path = path)