Man pages for testthat
Unit Testing for R

auto_testWatches code and tests for changes, rerunning tests as...
capture_conditionCapture conditions, including messages, warnings,...
capture_outputCapture output to console
CheckReporterReport results for R CMD check
compareProvide human-readable comparison of two objects
compare_stateCompare two directory states.
comparison-expectationsDo you expect a value bigger or smaller than this?
contextDescribe the context of a set of tests.
context_start_fileStart test context from a file name
DebugReporterInteractively debug failing tests
default_reporterRetrieve the default reporter
describedescribe: a BDD testing language
dir_stateCapture the state of a directory.
equality-expectationsDo you expect this value?
evaluate_promiseEvaluate a promise, capturing all types of output.
expectThe previous building block of all 'expect_' functions
expect_all_equalDo you expect every value in a vector to have this value?
expectationExpectation conditions
expect_equivalentIs an object equal to the expected value, ignoring...
expect_errorDo you expect an error, warning, message, or other condition?
expect_invisibleDo you expect the result to be (in)visible?
expect_isDo you expect to inherit from this class?
expect_known_outputDo you expect the results/output to equal a known value?
expect_lengthDo you expect an object with this length or shape?
expect_less_thanDeprecated numeric comparison functions
expect_matchDo you expect a string to match this pattern?
expect_namedDo you expect a vector with (these) names?
expect_no_errorDo you expect the absence of errors, warnings, messages, or...
expect_no_successTest for absence of success or failure
expect_nullDo you expect 'NULL'?
expect_outputDo you expect printed output to match this pattern?
expect_output_fileDo you expect the output/result to equal a known good value?
expect_referenceDo you expect a reference to this object?
expect_setequalDo you expect a vector containing these values?
expect_silentDo you expect code to execute silently?
expect_snapshotDo you expect this code to run the same way as last time?
expect_snapshot_fileDo you expect this code to create the same file as last time?
expect_snapshot_outputSnapshot helpers
expect_snapshot_valueDo you expect this code to return the same value as last...
expect_successTest your custom expectations
expect_thatExpect that a condition holds.
expect_vectorDo you expect a vector with this size and/or prototype?
extract_testExtract a reprex from a failed expectation
failDeclare that an expectation either passes or fails
FailReporterFail if any tests fail
find_reporterFind reporter object given name or object.
find_test_scriptsFind test files
inheritance-expectationsDo you expect an S3/S4/R6/S7 object that inherits from this...
is_informative_errorIs an error informative?
is_testingDetermine testing status
JunitReporterReport results in jUnit XML format
ListReporterCapture test results and metadata
local_editionTemporarily change the active testthat edition
local_mocked_bindingsTemporarily redefine function definitions
local_mocked_r6_classMock an R6 class
local_mocked_s3_methodMock S3 and S4 methods
local_snapshotterInstantiate local snapshotting context
local_test_contextTemporarily set options for maximum reproducibility
local_test_directoryLocally set test directory options
LocationReporterTest reporter: location
logical-expectationsDo you expect 'TRUE' or 'FALSE'?
make_expectationMake an equality test.
MinimalReporterReport minimal results as compactly as possible
mock_output_sequenceMock a sequence of output from a function
MultiReporterRun multiple reporters at the same time
notNegate an expectation
oldskoolOld-style expectations.
ProgressReporterReport progress interactively
quasi_labelQuasi-labelling
reexportsObjects exported from other packages
ReporterManage test reporting
reporter-accessorsGet and set active reporter.
RStudioReporterReport results to RStudio
run_cpp_testsDo C++ tests past?
set_max_failsSet maximum number of test failures allowed before aborting...
set_state_inspectorCheck for global state changes
SilentReporterSilently collect and all expectations
skipSkip a test for various reasons
skip_on_travisSuperseded skip functions
SlowReporterFind slow tests
snapshot_acceptAccept or reject modified snapshots
snapshot_download_ghDownload snapshots from GitHub
source_fileSource a file, directory of files, or various important...
StopReporterError if any test fails
succeedMark a test as successful
SummaryReporterReport a summary of failures
takes_less_thanDoes code take less than the expected amount of time to run?
TapReporterReport results in TAP format
TeamcityReporterReport results in Teamcity format
teardownRun code before/after tests
teardown_envRun code after all test files
test_dirRun all tests in a directory
test_envGenerate default testing environment.
test_examplesTest package examples
test_fileRun tests in a single file
test_packageRun all tests in a package
test_pathLocate a file in the testing directory
test_thatRun a test
testthat_examplesRetrieve paths to built-in example test files
testthat-packageAn R package to make testing fun!
testthat_resultsCreate a 'testthat_results' object from the test results as...
testthat_toleranceDefault numeric tolerance
topic-nameSimulate a test environment
try_againEvaluate an expectation multiple times until it succeeds
use_catchUse Catch for C++ unit testing
verify_outputVerify output
watchWatch a directory for changes (additions, deletions &...
with_mockMock functions in a package.
testthat documentation built on Nov. 25, 2025, 5:09 p.m.