1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tinytest.R
\name{test_package}
\alias{test_package}
\title{Test a package during R CMD check or after installation}
\usage{
test_package(
pkgname,
testdir = "tinytest",
lib.loc = NULL,
at_home = FALSE,
ncpu = NULL,
...
)
}
\arguments{
\item{pkgname}{\code{[character]} scalar. Name of the package, as in the \code{DESCRIPTION} file.}
\item{testdir}{\code{[character]} scalar. Path to installed directory. By default
tinytest assumes that test files are in \code{inst/tinytest/}, which means
that after installation and thus during \code{R CMD check} they are in
\code{tinytest/}. See details for using alternate paths.}
\item{lib.loc}{\code{[character]} scalar. location where the package is installed.}
\item{at_home}{\code{[logical]} scalar. Are we at home? (see Details)}
\item{ncpu}{A positive integer, or a \code{\link{makeCluster}} object.}
\item{...}{extra arguments passed to \code{\link{run_test_dir}} (e.g. \code{ncpu}).}
}
\value{
If \code{interactive()}, a \code{tinytests} object. If not
\code{interactive()}, an error is thrown when at least one test fails.
}
\description{
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 \code{R CMD check} or by a user that installed a package that
uses the \pkg{tinytest} test infrastructure.
}
\section{Details}{
We set \code{at_home=FALSE} by default so \code{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.
\code{vignette("using_tinytest",package="tinytest")}.
Package authors who want to avoid installing tests with the package can
create a directory under \code{tests}. If the test directoy is called
\code{"tests/foo"}, use \code{test_package("pkgname", testdir="foo")} in
\code{tests/tinytest.R}.
}
\examples{
\dontrun{
# 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")
}
}
\seealso{
\code{\link{setup_tinytest}}
Other test-files:
\code{\link{build_install_test}()},
\code{\link{exit_file}()},
\code{\link{run_test_dir}()},
\code{\link{run_test_file}()},
\code{\link{summary.tinytests}()}
}
\concept{test-files}
|