问题
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.
回答1:
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
回答2:
FYI: testthat
0.9 now comes with a skip()
function.
However, I can't seem to figure out how/where exactly to use it. Putting inside my test_that()
function, the test runs anyway. If you put it before testthat()
, then skip()
throws an error.
来源:https://stackoverflow.com/questions/25595487/testthat-pattern-for-long-running-tests