문제

I have written a series of test_that tests. There is one test_that test which has a side-effect of creating a sqlite3 table. The rest of the tests rely on this sqlite3 table. Is there a way to force this one test to run before any of the other tests do?

도움이 되었습니까?

해결책

If you are using test_dir or test_package (otherwise you can just put the tests in the same file after the sqlite test), you can put your test that generates the table in its own file and use naming conventions for execution. For example, inside tests/run.R you could have:

test_file("tests/testthat/myspecialfile.R")   
test_dir("tests/testthat/")   # will run every file with a name starting with `test`
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top