Execute code in the specified file, displaying results using a reporter.
Use this function when you want to run a single file's worth of tests.
You are responsible for ensuring that the functions to test are available
in the global environment.
test_file(path, reporter = default_reporter(), env = test_env(), start_end_reporter = TRUE, load_helpers = TRUE, encoding = "unknown", wrap = TRUE)
| path | Path to file. |
|---|---|
| reporter | Reporter to use to summarise output. Can be supplied
as a string (e.g. "summary") or as an R6 object
(e.g. See Reporter for more details and a list of built-in reporters. |
| env | Environment in which to execute the tests. Expert use only. |
| start_end_reporter | Should the reporters |
| load_helpers | Source helper files before running the tests?
See |
| encoding | Deprecated. All files now assumed to be UTF-8. |
| wrap | Automatically wrap all code within |
Invisibily, a list with one element for each test.
Any errors that occur in code run outside of test_that() will generate
a test failure and terminate execution of that test file.
#> .SW...# test_file() invisibly returns a list, with one element for each test. # This can be useful if you want to compute on your test results. out <- test_file(path, reporter = "minimal")#> .SW...#> List of 7 #> $ file : chr "test-success.R" #> $ context: NULL #> $ test : chr "one plus one is two" #> $ user : num 0.001 #> $ system : num 0 #> $ real : num 0.001 #> $ results:List of 1 #> ..$ :List of 6 #> .. ..$ message : chr "1 + 1 not equal to 2.\nEqual" #> .. ..$ srcref : 'srcref' int [1:8] 2 3 2 24 3 24 2 2 #> .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x562ecf2aac88> #> .. ..$ trace : NULL #> .. ..$ start_frame: int 64 #> .. ..$ end_frame : num 65 #> .. ..$ test : chr "one plus one is two" #> .. ..- attr(*, "class")= chr [1:3] "expectation_success" "expectation" "condition"