Function Mocking for Unit Testing
Overview
With the deprecation of mocking capabilities shipped with 'testthat' as of 'edition 3' it is left to third-party packages to replace this functionality, which in some test-scenarios is essential in order to run unit tests in limited environments (such as no Internet connection). Mocking in this setting means temporarily substituting a function with a stub that acts in some sense like the original function (for example by serving a HTTP response that has been cached as a file). The only exported function 'with_mock()' is modeled after the eponymous 'testthat' function with the intention of providing a drop-in replacement.
- Remove some tests: due to an internal change in jsonlite, this is no longer a useful example.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK14 OK2026-03-10
Documentation
- Help pages
- 2
- Examples that run
- 100%2 run in a plain check
- Exported functions with examples
- 100%
- Documented parameters
- 100%
- Return-value docs
- 100%
- Help pages citing references
- 0%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 9
- Median days to close, 50 most recently updated closed PRs
- 64
Stars over time
Forks over time
Issues over time
PRs over time
8 development-tooling and community-health practices detected across 4 families in the upstream repository
Checks run against github.com/nbenn/mockthat on 2026-10-18.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2022-10-31 · The repository has a site deploy workflow
Dependencies
Installing mockthat adds 1 package (1 with compiled code, 766 KB of source tarballs). Heaviest: rlang 766 KB.
Code & Tests
People & History
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- RR 4.3.0 released · 2023-04-21
- unarchivedReturned to CRAN2022-11-01
- 0.2.8Latest
- archivedRemoved from CRAN2022-10-18issues were not corrected in time
- RR 4.2.0 released · 2022-04-22
- RR 4.1.0 released · 2021-05-18
- 0.2.6
- 0.2.42020-12-09
- RR 4.0.0 released · 2020-04-24
Package metadata
- First published
- 2020-12-09
- Total releases
- 3 / 6 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 3.3.0
- Download size
- 13 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("mockthat")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.