testthat
3.3.2Unit Testing for R
Overview
Software testing is important, but, in part because it is frustrating and boring, many of us avoid it. 'testthat' is a testing framework for R that is easy to learn and use, and integrates with your existing 'workflow'.
- testthat now emits OpenTelemetry traces for tests when tracing is enabled. Requires the otel and otelsdk packages (#2282).
default_parallel_reporter()is no longer exported; usedefault_reporter(parallel = TRUE)instead (#2305).expect_snapshot()once again reports the original error class for base errors, rather thanrlang_error(#2286).expect_snapshot_file()once again works with shinytest2 on CI (#2293, #2288).expect_snapshot_file()correctly reports file name if duplicated (@MichaelChirico, #2296).expect_success()andexpect_failure()now always report the observed number of successes and failures (#2297).LlmReporter()is a new reporter designed for use by LLM coding agents. It's used automatically inside Claude Code, Cursor, and Gemini CLI, and you can setAGENT=1to use with any coding agent (#2287).local_mocked_s3_method()andlocal_mocked_s4_method()can now mock methods that don't already exist, and can usedefinition = NULLto temporarily remove a method.local_mocked_s4_method()now also works when the generic is defined in another package (#2302).local_snapshotter()restoressnap_dirto be the first argument for compatibility with devtools 2.4.6 (#2309).test_dir()no longer runs tests in parallel if only a single file is being tested (#2305).
From NEWS.md in the release
Install
Health
- OK13 OK2026-10-17
- WARNING12 OK, 1 WARNING2026-10-01
- OK13 OK2026-09-01
- ERROR12 OK, 1 ERROR2026-08-25
- OK13 OK2026-08-21
Show 16 earlier changesHide 16 earlier changes
- WARNING12 OK, 1 WARNING2026-08-20
- ERROR12 OK, 1 ERROR2026-08-12
- OK13 OK2026-08-04
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-07-13
- ERROR12 OK, 1 ERROR2026-07-11
- OK13 OK2026-05-30
- ERROR12 OK, 1 ERROR2026-05-28
- OK13 OK2026-05-05
- ERROR12 OK, 1 ERROR2026-05-04
- OK12 OK2026-04-25
- NOTE12 OK, 2 NOTE2026-04-20
- ERROR11 OK, 2 NOTE, 1 ERROR2026-04-18
- NOTE12 OK, 2 NOTE2026-04-15
- ERROR11 OK, 2 NOTE, 1 ERROR2026-04-12
- NOTE12 OK, 2 NOTE2026-03-10
Documentation
- Help pages
- 109 (51 internal)includes a package overview page
- Examples that run
- 95%39 run in a plain check (1 of them under a condition) · 2 never run
- Exported functions with examples
- 39%
- Documented parameters
- 80%
- Return-value docs
- 18%
- Help pages citing references
- 0%
- Custom expectations HTML
- Mocking HTML
- Running tests in parallel HTML
- Skipping tests HTML
- Snapshot tests HTML
- Special files HTML
- Test fixtures HTML
- Testing challenging functions HTML
- testthat 3e HTML
Downloads
Repository
- PRs merged (all time)
- 79%
- Median days to close, 50 most recently updated closed issues
- 11
- Median days to close, 50 most recently updated closed PRs
- 3
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
16 development-tooling and community-health practices detected across 7 families in the upstream repository
Checks run against github.com/r-lib/testthat on 2026-10-11.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-09-30 · The repository has a site deploy workflow
pkgdown site last built 2026-01-12
Show all practicesHide 3 practices
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2025-07-30Seen in the repository: .claude, .claude/skillsNamed in .Rbuildignore: .claude
Dependencies
Installing testthat adds 23 packages (10 with compiled code, 5.8 MB of source tarballs). Heaviest: fs 1.4 MB, jsonlite 1.0 MB, rlang 766 KB.
Show the 48 most downloaded dependentsHide the 48 most downloaded dependents
and 85 more dependents and 12,603 packages that suggest it on CRAN ↗
Code & Tests
People & History
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- 3.3.2Latest2026-01-11 · current release · diff ↗ ·
removed 1 export
default_parallel_reporteradded 1 export
LlmReporter - 3.3.12025-11-25 · diff ↗
- 3.3.02025-11-13 · diff ↗ ·
removed 4 exports
is_false, is_null, is_true, matchesadded 18 exports
SlowReporter, expect_all_equal, expect_all_false, expect_all_true, expect_disjoint, expect_r6_class, expect_shape, extract_test, local_mocked_r6_class, local_mocked_s3_method, local_mocked_s4_method, local_on_cran, mock_output_sequence, pass, simulate_test_env, skip_unless_r, snapshot_download_gh, snapshot_reject - RR 4.5.0 released · 2025-04-11
- 3.2.32025-01-13 · diff ↗
- 3.2.22024-12-10 · diff ↗ ·
added 4 exports
expect_no_failure, expect_no_success, expect_s7_class, expect_snapshot_failure - RR 4.4.0 released · 2024-04-24
- 3.2.1.12024-04-14 · diff ↗
- 3.2.12023-12-02 · diff ↗
- 3.2.02023-10-06 · diff ↗
- 3.1.102023-07-07 · diff ↗
- 3.1.92023-06-16 · diff ↗ ·
added 5 exports
expect_contains, expect_in, is_checking, is_snapshot, set_state_inspector - 3.1.8
- RR 4.3.0 released · 2023-04-21
- 3.1.7
Show 55 earlier eventsHide 55 earlier events
- 3.1.62022-12-10 · diff ↗
- 3.1.52022-10-08 · diff ↗ ·
added 5 exports
expect_no_condition, expect_no_error, expect_no_message, expect_no_warning, set_max_fails - 3.1.42022-04-26 · diff ↗
- RR 4.2.0 released · 2022-04-22
- 3.1.32022-03-29 · diff ↗
- 3.1.2
- 3.1.12021-12-03 · diff ↗
- 3.1.02021-10-04 · diff ↗
- 3.0.42021-07-01 · diff ↗
- 3.0.32021-06-17 · diff ↗ ·
added 4 exports
announce_snapshot_file, compare_file_binary, compare_file_text, expect_no_match - RR 4.1.0 released · 2021-05-18
- 3.0.22021-02-14 · diff ↗
- 3.0.1
- 3.0.02020-10-31 · diff ↗ ·
removed 1 export
expect_known_failureadded 23 exports
CompactProgressReporter, ParallelProgressReporter, context_start_file, default_compact_reporter, default_parallel_reporter, edition_get, expect_snapshot, expect_snapshot_error, expect_snapshot_file, expect_snapshot_output, expect_snapshot_value, is_parallel, local_edition, local_reproducible_output, local_snapshotter, local_test_context, local_test_directory, run_cpp_tests, snapshot_accept, snapshot_review, teardown_env, test_local, testthat_print - RR 4.0.0 released · 2020-04-24
- 2.3.22020-03-02 · diff ↗
- 2.3.12019-12-01 · diff ↗
- 2.3.02019-11-05 · diff ↗ ·
added 4 exports
exp_signal, is_informative_error, new_expectation, testthat_tolerance - 2.2.12019-07-25 · diff ↗
- 2.2.0
- RR 3.6.0 released · 2019-04-26
- 2.1.12019-04-24 · diff ↗
- 2.1.02019-04-23 · diff ↗ ·
removed 1 export
check_repoteradded 11 exports
check_reporter, expect_invisible, expect_mapequal, expect_vector, expect_visible, local_mock, skip_if_offline, skip_on_ci, testing_package, testthat_example, testthat_examples - 2.0.12018-10-13 · diff ↗
- RR 3.5.0 released · 2018-04-23
- 2.0.02017-12-13 · diff ↗ ·
added 29 exports
DebugReporter, JunitReporter, LocationReporter, ProgressReporter, capture_condition, capture_error, capture_expectation, capture_message, capture_output_lines, capture_warning, check_repoter, default_reporter, expect_condition, expect_known_failure, expect_known_hash, expect_known_output, expect_known_value, expect_reference, expect_setequal, is_testing, quasi_label, setup, show_failure, skip_if, skip_if_translated, source_test_setup, source_test_teardown, teardown, test_rd - RR 3.4.0 released · 2017-04-21
- RR 3.3.0 released · 2016-05-03
- 1.0.22016-04-23 · diff ↗
- 1.0.1
- 1.0.02016-04-14 · diff ↗ ·
added 19 exports
%>%, FailReporter, capture_messages, capture_output, capture_warnings, expect, expect_cpp_tests_pass, expect_failure, expect_length, expect_s3_class, expect_s4_class, expect_success, expect_type, skip_if_not, skip_on_bioc, source_file, test_path, try_again, use_catch - 0.11.02015-10-14 · diff ↗ ·
added 7 exports
expect_gt, expect_gte, expect_lt, expect_lte, expect_silent, skip_on_appveyor, skip_on_os - 0.10.02015-05-22 · diff ↗ ·
removed 2 exports
colourise, library_if_availableadded 10 exports
CheckReporter, RstudioReporter, compare, find_test_scripts, skip_if_not_installed, skip_on_travis, source_test_helpers, succeed, test_example, test_examples - RR 3.2.0 released · 2015-04-16
- 0.9.12014-10-01 · diff ↗
- 0.92014-09-22 · diff ↗ ·
added 6 exports
describe, equals_reference, expect_equal_to_reference, skip, skip_on_cran, with_mock - RR 3.1.0 released · 2014-04-10
- 0.8.12014-02-22 · diff ↗
- 0.82014-02-20 · diff ↗ ·
added 21 exports
ListReporter, MultiReporter, Reporter, SilentReporter, TeamcityReporter, evaluate_promise, expect_less_than, expect_more_than, expect_named, expect_null, get_reporter, has_names, is.expectation, is_less_than, is_more_than, is_null, not, set_reporter, test_check, test_env, with_reporter - RR 3.0.0 released · 2013-04-03
- 0.7.1
- 0.7
- RR 2.15.0 released · 2012-03-30
- 0.62011-12-30 · diff ↗
- RR 2.14.0 released · 2011-10-31
- 0.52011-06-01 · diff ↗
- RR 2.13.0 released · 2011-04-13
- 0.4
- RR 2.12.0 released · 2010-10-15
- 0.32010-08-31 · diff ↗ ·
added 14 exports
expect_is, expect_true, expect_false, expect_equal, expect_equivalent, expect_identical, expect_match, expect_output, expect_error, gives_warning, expect_warning, shows_message, expect_message, test_package - 0.22010-07-25 · diff ↗ ·
added 24 exports
auto_test, auto_test_package, colourise, context, expect_that, is_a, is_true, is_false, equals, is_equivalent_to, is_identical_to, matches, prints_text, throws_error, takes_less_than, library_if_available, MinimalReporter, StopReporter, SummaryReporter, test_dir, source_dir, test_file, test_that, watch - RR 2.11.0 released · 2010-04-22
- 0.1.12009-11-30 · diff ↗
- 0.12009-11-17
- RR 2.10.0 released · 2009-10-26
Package metadata
- First published
- 2009-11-17
- Total releases
- 51 / 17 yrs
- License
- MIT + file LICENSE OSI · relicensed from GPL in 0.8
- Minimum R
- ≥ 4.1.0
- Download size
- 814 KB
Cite
Cite this package
Run in R for the authors' entry:
citation("testthat")The package provides a citation file, so citation() returns the authors' own entry.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-17, which the citation names so these numbers can be found later. More on citing and the projects behind them.