How to run a package's testthat tests
R doesn't install the testthat tests by default. To do so try :
install.packages('eplusr', INSTALL_opts="--install-tests", type='source')
Then, either:
testthat::test_package('eplusr')
or alternatively using the built-in testInstalledPackage
:
tools::testInstalledPackage('eplusr')
You can't (unless you reinstall overriding default behaviour as shown in Brodie's answer).
It's a design flaw^Hchoice. testthat
, in all its wisdom, decided to not install tests by default by enforcing the placement in the tests/
directory. R offers an option to override it (as shown) which is generally not turned on. Hence the dilemma.
Of course, RUnit
did it correctly all along having tests below inst/
. So if a package uses RUnit
you can run its tests once installed. Without having to reinstall it.
Edit: 1 1/2 years later, many of us now use the tinytest package which arrived within the last year. Among other advantages, also allows very easy testing of installed packages.