Skip to content
A minimal, low-dependency package for unit testing
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



A minimal, no-dependency package for unit testing

tinytest philosophy.

Testing should be as easy as possible.

Testing infrastructure must not get in the way of the developer. Setting up tests should be done with ease. In tinytest tests are simple R-scripts where test statements can be intersperced with other code (e.g. to prepare some results for testing).

Test results are data

The purpose of testing is to gather evidence (data) that builds confidence in the quality of software. Unit tests consist of expressions where an expected result is compared with the result of a program or function. For example:

addOne <- function(x) x + 1
subOne <- function(x) x - 2

# this test should be passed
tinytest::expect_equal(2, addOne(1) )

# this test will fail
tinytest::expect_equal(1, subOne(2) ) 

Commonly used unit testing frameworks for R throw a formal exception (error) whenever a test fails. There are several reasons why this is not a good idea.

  1. You do not need to throw an error to discover that a test has failed. A boolean result is in principle enough.
  2. A traceback of the error does not give you any information on the cause of the test failure. This is because the test function throws the error, not the tested code.
  3. Throwing errors complicates the code needed for developing a testing suite, making testing suites harder to maintain and possibly more complex to use than necessary.

tinytest therefore treats test results as data, not as exceptions. This data can be summarized and investigated by any method you already know in R.

Error on deploy

There is a case where the failure of a test should cause an error, namely when testing for deployment (e.g. publishing a package on CRAN). Therefore, when running of R CMD check, an error will be thrown if a test is failed. This way the error interrupts the deployment process instead of the testing process.

Run all tests

By default all tests are run and the results are summarized to one line of output per failed result.

Tests are installed with the package

So a package author can request test results from users that installed the package on a local system.

Show you what you need

Developing and debugging takes focus and often deep concentration. tinytest supports your workflow by directing you as quickly as possible to the source of the test failure. In a single line of output you get the test result, the file and location in the file, and the test call that failed.

Light weight is the right weight

Keep it simple, keep it clean. See

You can’t perform that action at this time.