1: The Basics

The most popular testing framework for R packages is {testthat}.
Therefore we show here the {testthat} syntax, but the structure is similar in other frameworks.
{testthat}?All comparisons start with expect_ prefix and take result and expected as arguments.
They will throw an error if the comparison evaluates to a value different than what is expected.
expect_identical() # exact identity
expect_equal() # equal up to numerical tolerance
expect_match() # character matches regular expression
expect_silent() # no message, warning, error is produced
expect_warning() # (specific) warning occurs
expect_error() # (specific) error occurs
expect_is() # object is of specific class
expect_true(), expect_false() # general usage“Wait a second …
R packages contain example code for documented functions or objects.
These are automatically executed by R CMD CHECK.
So this sounds sufficient, right? …”
→ Not really!
set.seed()).Unit tests …

