testdata folder.Save R objects to separate files tests/testthat/testdata in the
.rds format.
use_testdata(
...,
subdir = NULL,
overwrite = FALSE,
ignore = FALSE,
compress = TRUE,
refhook = NULL,
version = NULL
)use_testdata_raw(name = NULL)
has_testdata()
read_testdata(infile, subdir = NULL)
find_testdata(..., path = ".", must_exist = FALSE)
R objects to save to the testdata dir. If empty,
an empty directory is created.
character scalar. Subdirectory of testdata to save
to / read from.
Logical scalar. Should existing files be overwritten?
Should the newly created file be added to .Rbuildignore?
a logical specifying whether saving to a named file is
to use "gzip" compression, or one of "gzip",
"bzip2" or "xz" to indicate the type of compression to
be used. Ignored if file is a connection.
a hook function for handling reference objects.
the workspace format version to use. NULL
specifies the current default version (3). The only other supported
value is 2, the default from R 1.4.0 to R 3.5.0.
a character scalar or NULL. Name of the dataset for which
to create a script file in testthat/testdata-raw. If NULL an empty
testthat/testdata-raw directory is created (if it does not exist
already).
rds file to read (must end in .rds, otherwise .rds ending is automatically added)
Path of the directory to create, relative to the project.
logical scalar. Assert that path specified in ...
exists
use_testdata() returns TRUE if object was successfully saved.
has_testdata() returns TRUE if package has a
tests/testthat/testdata folder.
read_testdata() returns a single R object
find_testdata() returns the normalized path to a file in a
in the testdata directory
use_testdata() saves an R object to a testdata dir in the current package.
Other infrastructure:
use_test_subdir(),
use_tester()
# NOT RUN {
use_testdata(letters, LETTERS)
# }
Run the code above in your browser using DataLab