What is the proper way to skip all tests in the test directory of an R package when using testthat/devtools infrastructure? For example, if there is no connection to a database and all the tests rely on that connection, do I need to write a skip
in all the files individually or can I write a single skip
somewhere?
I have a standard package setup that looks like
mypackage/
- ... # other package stuff
- tests/
- testthat.R
- testthat/
- test-thing1.R
- test-thing2.R
At first I thought I could put a test in the testthat.R
file like
## in testthat.R
library(testthat)
library(mypackage)
fail_test <- function() FALSE
if (fail_test()) test_check("package")
but, that didn't work and it looks like calling devtools::test()
just ignores that file. I guess an alternative would be to store all the tests in another directory, but is there a better solution?
if( fail_test() )
... – Myosin