unitizeR - Interactive R Unit Tests

Dependencies direct/recursive Project Status: WIP - Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.


unitizer simplifies creating, reviewing, and debugging unit tests in R. To install:


Please keep in mind this is an experimental framework that has been thoroughly tested by one person.

unitizer bakes in a lot of contextual help so you can get started without reading all the documentation. Try the demo to get an idea:


Or check out the screencast to see unitizer in action.

Why Another Testing Framework?

Automated Test Formalization

Are you tired of the deparse/dput then copy-paste R objects into test file dance, or do you use testthat::expect_equal_to_reference a lot?

With unitizer you review function output at an interactive prompt as you would with informal tests. You then store the value, conditions (e.g. warnings, etc.), and environment for use as the reference values in formal tests, all with a single keystroke.

Streamlined Debugging

Do you wish the nature of a test failure was more immediately obvious?

When tests fail, you are shown a proper diff so you can clearly identify how the test failed:

diff example

Do you wish that you could start debugging your failed tests without additional set-up work?

unitizer drops you in the test environment so you can debug why the test failed without further ado:

review example

Fast Test Updates

Do you avoid improvements to your functions because that would require painstakingly updating many tests?

The diffs for the failed tests let you immediately confirm only what you intended changed. Then you can update each test with a single keystroke.


unitizer stores R expressions and the result of evaluating them so that it can detect code regressions. This is akin to saving test output to a .Rout.save file as documented in Writing R Extensions, except that we’re storing the actual R objects and it is much easier to review them.

To use unitizer:

unitizer can run in a non-interactive mode for use with R CMD check.



Thank you to:

About the Author

Brodie Gaslam is a hobbyist programmer based in the US East Coast.