Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

testthat pattern for long-running tests

Tags:

r

cran

testthat

I have a bunch of tests that I don't want them running during CRAN checks or Travis CI builds. They are either long-running, or they could cause transaction/concurrency conflicts writing to a networked database. What approach of separating them (from the R CMD check tests) works best with testthat?

Should I put those tests in a separate folder? Should I tag their filename and use a regex? (eg Using filter argument in test_package to skip tests by @Jeroen)

http://cran.r-project.org/web/packages/policies.html:

Long-running tests and vignette code can be made optional for checking, but do ensure that the checks that are left do exercise all the features of the package.

like image 279
wibeasley Avatar asked Aug 31 '14 19:08

wibeasley


People also ask

How do you run a Testthat test?

If you're using RStudio, press Cmd/Ctrl + Shift + T (or run devtools::test() if not) to run all the tests in a package.

What is Testthat?

'testthat' is a testing framework for R that is easy to learn and use, and integrates with your existing 'workflow'. License MIT + file LICENSE. URL https://testthat.r-lib.org, https://github.com/r-lib/testthat.


1 Answers

If you put them in another directory within tests, then you can still test them manually with test_dir(), but they won't be running with test() or R CMD check.

E.g. R6 has some manual tests: https://github.com/wch/R6/tree/master/tests

like image 76
Gabor Csardi Avatar answered Sep 19 '22 18:09

Gabor Csardi