Last data update: 2014.03.03

R: Run all tests in an installed package.
test_packageR Documentation

Run all tests in an installed package.

Description

Test are run in an environment that inherits from the package's namespace environment, so that tests can access non-exported functions and variables. Tests should be placed in tests/testthat. Use test_check with R CMD check and test_package interactively at the console.

Usage

test_package(package, filter = NULL, reporter = "summary", ...)

test_check(package, filter = NULL, reporter = "check", ...)

Arguments

package

package name

filter

If not NULL, only tests with file names matching this regular expression will be executed. Matching will take on the file name after it has been stripped of "test-" and ".R".

reporter

reporter to use

...

Additional arguments passed to grepl to control filtering.

Value

the results as a "testthat_results" (list)

R CMD check

Create tests/testthat.R that contains:

library(testthat)
library(yourpackage)

test_check("yourpackage")

Examples

## Not run: test_package("testthat")

Results