register_tinytest_extension {tinytest} | R Documentation |
Register or unregister extension functions
Description
Functions to use in .onLoad
and .onUnload
by packages that
extend tinytest.
Usage
register_tinytest_extension(pkg, functions)
Arguments
pkg |
|
functions |
|
The tinytest API
Packages can extend tinytest with expectation functions if and only if the following requirements are satisfied.
The extending functions return a
tinytest
object. This can be created by callingtinytest()
with the arguments (defaults, if any, are in brackets):result
: Alogical
scalar:TRUE
orFALSE
(notNA
)call
: Thecall
to the expectation function. Usually the result ofsys.call(sys.parent(1))
diff
(NA_character_
): Acharacter
scalar, with a long description of the difference. Sentences may be separated by"\n"
.short
(NA_character_
): Either"data"
, if the difference is in the data."attr"
when attributes differ or"xcpt"
when an expectation about an exception is not met. If there are differences in data and in attributes, the attributes take precedence.info
(NA_character_
): A user-defined message.
Observe that this requires the extending package to add tinytest to the
Imports
field in the package'sDESCRIPTION
file (this also holds for the following requirement).Functions are registered in
.onLoad()
usingregister_tinytest_extension()
. Functions that are already registered, including tinytest functions will be overwritten.
It is recommended to:
Follow the syntax conventions of tinytest so expectation functions start with
expect_
.Explain to users of the extension package how to use the extension (see
using
).include an
info
argument toexpect_
functions that is passed totinytest()
.
Minimal example packages
Extending tinytest: tinytest.extension.
Using a tinytest extension: using.tinytest.extension.
See Also
Other extensions:
tinytest()
,
using()