Skip to content

Expectations

Objects

expect_equal() expect_identical()
Does code return the expected value?
expect_type() expect_s3_class() expect_s4_class()
Does code return an object inheriting from the expected base type, S3 class, or S4 class?

Vectors

expect_length()
Does code return a vector with the specified length?
expect_lt() expect_lte() expect_gt() expect_gte()
Does code return a number greater/less than the expected value?
expect_named()
Does code return a vector with (given) names?
expect_setequal() expect_mapequal()
Does code return a vector containing the expected values?
expect_true() expect_false()
Does code return TRUE or FALSE?
expect_vector()
Does code return a vector with the expected size and/or prototype?

Side-effects

expect_error() expect_warning() expect_message() expect_condition()
Does code throw an error, warning, message, or other condition?
expect_invisible() expect_visible()
Does code return a visible or invisible object?
expect_output()
Does code print output to the console?
expect_silent()
Does code execute silently?
local_test_context() local_reproducible_output()
Locally set options for maximal test reproducibility

Snapshot testing

Test helpers

Run tests

auto_test()
Watches code and tests for changes, rerunning tests as appropriate.
auto_test_package()
Watches a package for changes, rerunning tests as appropriate.
describe()
describe: a BDD testing language
test_file()
Run all tests in a single file
test_package() test_check() test_local()
Run all tests in a package
test_path()
Locate file in testing directory.
test_that()
Run a test
use_catch()
Use Catch for C++ Unit Testing

Reporters

CheckReporter
Check reporter: 13 line summary of problems
DebugReporter
Test reporter: start recovery.
FailReporter
Test reporter: fail at end.
JunitReporter
Test reporter: summary of errors in jUnit XML format.
ListReporter
List reporter: gather all test results along with elapsed time and file information.
LocationReporter
Test reporter: location
MinimalReporter
Test reporter: minimal.
MultiReporter
Multi reporter: combine several reporters in one.
ProgressReporter
Test reporter: interactive progress bar of errors.
RStudioReporter
Test reporter: RStudio
SilentReporter
Test reporter: gather all errors silently.
StopReporter
Test reporter: stop on error
SummaryReporter
Test reporter: summary of errors.
TapReporter
Test reporter: TAP format.
TeamcityReporter
Test reporter: Teamcity format.

Expectation internals

expect()
The building block of all expect_ functions
fail() succeed()
Default expectations that always succeed or fail.