Changelog
Source:NEWS.md
CHANGES IN testit VERSION 1.0
CRAN release: 2026-05-13
test_pkg()now checkscommandArgs(TRUE)for--filter=PATTERNand--updatewhen thefilterandupdatearguments are not explicitly provided. This allows you to runRscript tests/*.R --filter=PATTERN --updatewithout modifying individualtest_pkg()calls.The
factargument ofassert()now works with any character value, not just string literals. For example,assert(paste('test', name), { ... })andassert(msg, { ... })now work correctly.()test conditions insideassert('fact', { ... })now work insideif,for,while, andrepeatbodies. Previously only top-level()expressions in{}were checked. Only statement-level()is treated as a test; parentheses used for grouping within expressions (e.g.,(a + b) * c) are not affected. The entire{}block is now evaluated in a single frame, soon.exit()works as expected insideassert().Error messages from
assert()andtest_pkg()are no longer truncated by R’swarning.lengthoption (default 1000 characters). Previously, when many test failures accumulated, the combined error message could exceed the limit and lose trailing failures (thanks, @jdblischak, #24).test_pkg()gained afilterargument that takes a regular expression to selectively run a subset of test files (e.g.,test_pkg(filter = 'parse')runs only files with “parse” in their names).test_pkg()now runs all test files instead of stopping at the first failure. Errors are collected and reported together at the end, including multiple errors within a single file (thanks, @jdblischak, #19). The relative filename of each test is printed before execution.assert()now includes the actual value of the failed expression in the error message, making it easier to diagnose assertion failures (e.g.,(x %==% y) is not TRUE but FALSE).has_message(),has_warning(), andhas_error()gained amessageargument for matching the condition message viagrepl(), and...for passing additional arguments togrepl()(e.g.,fixed = TRUE,ignore.case = TRUE).Added support for helper files in tests. Helper files matching
helper*.Rare sourced into a dedicated environment before tests run, and their objects are available to all tests and snapshots.Fixed a bug in
test_snaps()where a code block without an output block would incorrectly claim a later output block (belonging to a subsequent code block) instead of inserting a new one.has_error()is now always silent (no longer prints error messages to the console), and itssilentargument has been removed.test_pkg()now suppresses messages and warnings from test scripts, helper files, and snapshot code evaluation. Diagnostic output (diffs, error locations) is emitted viamessage()so it can be suppressed by callers if needed.Error messages now include precise source locations (file and line number).
assert()reports the exact line of the failing sub-expression, andtest_pkg()reports error locations in test scripts, helper files, and snapshot code blocks.test_pkg()now installs the package to the system temp directory instead of a localR-lib-*folder, and fixes DLL cleanup on Windows so the temporary library can be properly removed (thanks, @jdblischak, #20).test_pkg()no longer reinstalls the package unnecessarily when called multiple times in the same session. It compares source file modification times against the installed package timestamp to decide if reinstallation is needed.
CHANGES IN testit VERSION 0.18
CRAN release: 2026-04-21
Snapshot tests now support both
```rand```{r}R code fences, and snapshot updates preserve the original fence style.Added and updated snapshot tests (including
mini_diff()output snapshots) and refreshed snapshot testing documentation/examples.
CHANGES IN testit VERSION 0.17
CRAN release: 2026-03-06
- Made
test_pkg()compatible with R < 3.3.0 (again).
CHANGES IN testit VERSION 0.16
CRAN release: 2026-02-23
- Added support for snapshot testing with Markdown files; see https://pkg.yihui.org/testit/#snapshot-testing for more information.
CHANGES IN testit VERSION 0.15
CRAN release: 2025-12-19
The error location reporting stopped working in the previous version and was fixed in this version.
The error location will come with a clickable link on it if the environment supports ANSI links.
CHANGES IN testit VERSION 0.14
CRAN release: 2025-12-06
test_pkg()is compatible with R < 3.3.0 (if the function.traceback()is unavailable, the error location will not be printed).Re-licensed the package to MIT.
CHANGES IN testit VERSION 0.13
CRAN release: 2021-04-14
- The global option
options(testit.cleanup = TRUE)(TRUEis the default) can be used to clean up additional files or directories generated in thetests/directory during the test process.
CHANGES IN testit VERSION 0.12
CRAN release: 2020-09-25
-
test_pkg()installs the package before running tests when it is called from a non-interactive R session that is not launched byR CMD check, e.g., when you run tests in RStudio viaCtrl/Cmd + Shift + T, so you will not have to install the package manually (Ctrl/Cmd + Shift + B) before running tests.
CHANGES IN testit VERSION 0.10
CRAN release: 2019-10-01
-
test_pkg()also looks for tests under thetests/testit/directory. This makes it easier for you to runtest_pkg()under the root directory of the package, and you don’t need to change the working directory totests/.
CHANGES IN testit VERSION 0.9
CRAN release: 2018-12-05
- Added a new argument
silentto has_error() (thanks, @StevenMMortimer, #6).
CHANGES IN testit VERSION 0.8
CRAN release: 2018-06-14
- When
%==%is used inside assert(), a message will be printed if the value is not TRUE, to show the values of the LHS and RHS, respectively.
CHANGES IN testit VERSION 0.7
CRAN release: 2017-05-22
- provided an alternative way to write assertions of the form assert(‘fact’, {(condition_2); (condition_2)}); see ?testit::assert for more information
CHANGES IN testit VERSION 0.5
CRAN release: 2016-02-17
added an infix operator
%==%as an alias of identical() (in RStudio, you can use an add-in to insert the text%==%)test_pkg() will print out the filename of the R script that errored
CHANGES IN testit VERSION 0.3
CRAN release: 2013-10-26
the test files have to be named of the form test-.R (or test-.r), i.e. they have to use the prefix test-
the test environment is always cleaned (all objects removed) before the next test is run
CHANGES IN testit VERSION 0.2.1
CRAN release: 2013-07-30
- fixed a test that failed under R 2.15.x because the argument keep.source did not exist in parse()
CHANGES IN testit VERSION 0.2
CRAN release: 2013-07-29
- assert() does not use base::stopifnot() any more; a tailored version of stopifnot() is used now; see ?assert for the differences between this version and base::stopifnot(); in particular, assert(fact, logical(0)) will fail but stopifnot(logical(0)) will not
CHANGES IN testit VERSION 0.1
CRAN release: 2013-06-28
this is the first version of testit; the source code is hosted on Github: https://github.com/yihui/testit
added functions assert(), test_pkg(), has_error() and has_warning()