Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我写了一系列 test_that 测试。有一个 test_that 测试具有创建 sqlite3 表的副作用。其余的测试依赖于这个 sqlite3 表。有没有办法强制这个测试在其他任何测试之前运行?
如果您正在使用test_diror test_package(否则您可以在 sqlite 测试之后将测试放在同一个文件中),您可以将生成表的测试放在自己的文件中并使用命名约定来执行。例如,在里面tests/run.R你可以有:
test_dir
test_package
tests/run.R
test_file("tests/testthat/myspecialfile.R") test_dir("tests/testthat/") # will run every file with a name starting with `test`