Learn R Programming

⚠️There's a newer version (3.2.3) of this package.Take me there.

testthat (version 1.0.0)

Unit Testing for R

Description

A unit testing system designed to be fun, flexible and easy to set up.

Copy Link

Version

Install

install.packages('testthat')

Monthly Downloads

397,049

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Hadley Wickham

Last Published

April 14th, 2016

Functions in testthat (1.0.0)

expect_equal_to_reference

Expectation: is the object equal to a reference value stored in a file?
dir_state

Capture the state of a directory.
compare_state

Compare two directory states.
SilentReporter

Test reporter: gather all errors silently.
RstudioReporter

Test reporter: RStudio
expectation

Expectation class.
use_catch

Use Catch for C++ Unit Testing
context

Describe the context of a set of tests.
equality-expectations

Expectation: is the object equal to a value?
fail

Default expectations that alway succeed or fail.
evaluate_promise

Evaluate a promise, capturing all types of output.
watch

Watch a directory for changes (additions, deletions & modifications).
safe_digest

Compute a digest of a filename, returning NA if the file doesn't exist.
logical-expectations

Expectation: is the object true/false?
expect_that

Expect that a condition holds.
find_test_scripts

Find the test files.
reexports

Objects exported from other packages
test_that

Create a test.
output-expectations

Expectation: does code produce output/message/warning/error?
Reporter

Stub object for managing a reporter of tests.
find_reporter

Find reporter object given name or object.
auto_test_package

Watches a package for changes, rerunning tests as appropriate.
test_package

Run all tests in an installed package.
MinimalReporter

Test reporter: minimal.
inheritance-expectations

Expectation: does the object inherit from a S3 or S4 class, or a base type?
StopReporter

Test reporter: stop on error.
ListReporter

List reporter: gather all test results along with elapsed time and file information.
TapReporter

Test reporter: TAP format.
with_mock

Mock functions in a package.
describe

describe: a BDD testing language
oldskool

Old-style expectations.
expect_match

Expectation: does string/output/message/warning/error match a regular expression?
takes_less_than

Expectation: does expression take less than a fixed amount of time to run?
source_file

Source a file, directory, or all helpers.
CheckReporter

Check reporter: 13 line summary of problems
test_dir

Run all of the tests in a directory.
SummaryReporter

Test reporter: summary of errors.
expect_cpp_tests_pass

Test Compiled Code in a Package
compare

Provide human-readable comparison of two objects
expect_length

Expectation: does a vector have the specified length?
test_file

Run all tests in specified file.
testthat_results

Create a `testthat_results` object from the test results as stored in the ListReporter results field.
reporter-accessors

Get/set reporter; execute code in specified reporter.
skip

Skip a test.
test_examples

Test package examples
not

Negate an expectation
testthat

R package to make testing fun!
auto_test

Watches code and tests for changes, rerunning tests as appropriate.
make_expectation

Make an equality test.
expect_success

Tools for testing expectations
FailReporter

Test reporter: fail at end.
test_env

Generate default testing environment.
MultiReporter

Multi reporter: combine several reporters in one.
TeamcityReporter

Test reporter: Teamcity format.
comparison-expectations

Expectation: is returned value less or greater than specified value?
test_path

Locate file in testing directory.
expect_named

Expectation: does object have names?
try_again

Try evaluating an expressing multiple times until it succeeds.