testthat pattern for long-running tests

江枫思渺然 提交于 2019-11-30 16:47:17

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!