Skip to contents

CHANGES IN testit VERSION 1.1

CRAN release: 2026-06-18

  • test_pkg() now sources global helper files (helper*.R) from the parent directory of the test directory before sourcing helpers in the test subdirectory itself. This allows sharing common test utilities across multiple test subdirectories (e.g., tests/testit/, tests/test-cran/).

CHANGES IN testit VERSION 1.0

CRAN release: 2026-05-13

  • test_pkg() now checks commandArgs(TRUE) for --filter=PATTERN and --update when the filter and update arguments are not explicitly provided. This allows you to run Rscript tests/*.R --filter=PATTERN --update without modifying individual test_pkg() calls.

  • The fact argument of assert() now works with any character value, not just string literals. For example, assert(paste('test', name), { ... }) and assert(msg, { ... }) now work correctly.

  • () test conditions inside assert('fact', { ... }) now work inside if, for, while, and repeat bodies. 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, so on.exit() works as expected inside assert().

  • Error messages from assert() and test_pkg() are no longer truncated by R’s warning.length option (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 a filter argument 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(), and has_error() gained a message argument for matching the condition message via grepl(), and ... for passing additional arguments to grepl() (e.g., fixed = TRUE, ignore.case = TRUE).

  • Added support for helper files in tests. Helper files matching helper*.R are 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 its silent argument 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 via message() 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, and test_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 local R-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 ```r and ```{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

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) (TRUE is the default) can be used to clean up additional files or directories generated in the tests/ 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 by R CMD check, e.g., when you run tests in RStudio via Ctrl/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.11

CRAN release: 2019-11-12

  • The package license was changed from GPL to GPL-3 (@jayvdb #8).

CHANGES IN testit VERSION 0.10

CRAN release: 2019-10-01

  • test_pkg() also looks for tests under the tests/testit/ directory. This makes it easier for you to run test_pkg() under the root directory of the package, and you don’t need to change the working directory to tests/.

CHANGES IN testit VERSION 0.9

CRAN release: 2018-12-05

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.6

CRAN release: 2016-11-09

  • test_pkg() runs package tests with top-level environment being set to the namespace of the tested package (thanks, @kalibera, #3)

  • all test scripts (test-*.R) are assumed to be encoded in UTF-8 if they contain multibyte characters

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.4

CRAN release: 2014-12-20

  • the fact argument of assert() is optional now: all arguments of assert() can be test conditions

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()