- The global option
options(testit.cleanup = TRUE)
(TRUE
is the default) can be used to clean up additional files or directories generated in thetests/
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 byR CMD check
, e.g., when you run tests in RStudio viaCtrl/Cmd + Shift + T
, so you will not have to install the package manually (Ctrl/Cmd + Shift + B
) before running tests.
- The package license was changed from GPL to GPL-3 (@jayvdb #8).
test_pkg()
also looks for tests under thetests/testit/
directory. This makes it easier for you to runtest_pkg()
under the root directory of the package, and you don't need to change the working directory totests/
.
- Added a new argument
silent
to has_error() (thanks, @StevenMMortimer, #6).
- 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.
- provided an alternative way to write assertions of the form assert('fact', {(condition_2); (condition_2)}); see ?testit::assert for more information
-
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
- the
fact
argument ofassert()
is optional now: all arguments ofassert()
can be test conditions
-
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
- fixed a test that failed under R 2.15.x because the argument keep.source did not exist in parse()
- 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
-
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()