测试长期运行的测试模式 [英] testthat pattern for long-running tests
问题描述
我有很多测试,我不希望它们在CRAN检查或Travis CI构建期间运行.它们要么运行时间长,要么可能会导致写入网络数据库的事务/并发冲突.哪种方法(与R CMD检查测试分开)与测试那个最有效?
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?
我应该将这些测试放在单独的文件夹中吗?我应该标记他们的文件名并使用正则表达式吗? (例如在test_package中使用过滤器参数来跳过测试通过@Jeroen)
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.
推荐答案
如果将它们放在tests
内的另一个目录中,则仍然可以使用test_dir()
手动对其进行测试,但是它们将不能与test()
或R CMD check
.
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
.
例如R6有一些手动测试: https://github.com/wch/R6/tree/master/测试
E.g. R6 has some manual tests: https://github.com/wch/R6/tree/master/tests
这篇关于测试长期运行的测试模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!