当我的R软件包目录结构直接在Tests文件夹中具有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
测试的文件。而且此功能在文件夹中不会递归,因此本地否,testthat
无法在内部目录内进行测试。
但是,您仍然可以这样运行测试:
my_test <- list.files(path = "tests", pattern = "test_|help_", recursive = TRUE, full.names = TRUE)
lapply(my_test, test_file)