test_package | R Documentation |
Run all tests in an installed package. Throw an error and print all failed test
results when one or more tests fail if not in interactive mode (e.g. when
R CMD check tests a package). This function is intended to be
used by R CMD check
or by a user that installed a package that
uses the tinytest test infrastructure.
test_package( pkgname, testdir = "tinytest", lib.loc = NULL, at_home = FALSE, ncpu = NULL, ... )
pkgname |
|
testdir |
|
lib.loc |
|
at_home |
|
ncpu |
A positive integer, or a |
... |
extra arguments passed to |
If interactive()
, a tinytests
object. If not
interactive()
, an error is thrown when at least one test fails.
We set at_home=FALSE
by default so R CMD check
will run the
same as at CRAN. See the package vignette (Section 4) for tips on how to set
up the package structure.
vignette("using_tinytest",package="tinytest")
.
Package authors who want to avoid installing tests with the package can
create a directory under tests
. If the test directoy is called
"tests/foo"
, use test_package("pkgname", testdir="foo")
in
tests/tinytest.R
.
setup_tinytest
Other test-files:
build_install_test()
,
exit_file()
,
run_test_dir()
,
run_test_file()
,
summary.tinytests()
## Not run: # Create a file with the following content, to use # tinytest as your unit testing framework: if (requireNamespace("tinytest", quietly=TRUE)) tinytest::test_package("your package name") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.