dimanche 5 mai 2019

How to share a common R context amongst a subset of tests?

I am working on an R package, using testthat package to automate tests (à la Hadley).

Part of the tests need to access a set of files, stored into the package under folder inst/testdata (see Where to put data for automated tests with testthat?).

What is the good practice to do so ?

According to https://www.tidyverse.org/articles/2017/12/testthat-2-0-0/, I should create a setup-xyz.R function in the test/testthat folder, where xyz stands for a function name.

If my subset of tests is large (hundreds of test) this ends up not to be really practiceable. Any proven smart solution suggestion ?

setup( {
lf <- list.files('../../inst/testdata', all.files = TRUE, full.names = TRUE)
}
)

Aucun commentaire:

Enregistrer un commentaire