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.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.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/
.silent
to has_error() (thanks, @StevenMMortimer, #6).%==%
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.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
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
fact
argument of assert()
is optional now: all arguments of assert()
can be test conditionsthe 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
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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.