作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我的 R 包目录结构在测试文件夹中直接包含 R 文件时
.
+--Projroot
+---- R
| -- routine1.R
| -- routine2.R
+---- tests
-- test_routine1.R
-- test_routine2.R
testthat
捕获 test_*.R
文件,但是当测试本身依赖于大量文件时,拥有测试子目录会更干净
.
+--Projroot
+---- R
| -- routine1.R
| -- routine2.R
+---- tests
|
+---- test_routine1
| -- test_routine1.R
| -- help_file11
| -- help_file12
+---- test_routine2
-- test_routine2.R
-- help_file21
-- help_file22
仅运行 devtools::test()
不会捕获内部目录中的 test_*.R
文件。
有没有办法使 testthat
递归搜索?
最佳答案
devtools::test()
调用 testthat::test_dir
。
testthat::test_dir
查找要使用 testthat::find_test_scripts
测试的文件。并且此函数不会递归地查看文件夹内部,因此 native 不会,testthat
将无法在内部目录中进行测试。
不过,您仍然可以通过这种方式运行测试:
my_test <- list.files(path = "tests", pattern = "test_|help_", recursive = TRUE, full.names = TRUE)
lapply(my_test, test_file)
关于r - 有没有办法递归地进行 testthat 搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48991329/
我是一名优秀的程序员,十分优秀!