test_file {testthat} | R Documentation |
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 |
Any errors that occur in code run outside of test_that()
will generate
a test failure and terminate execution of that test file.
Invisibily, a list with one element for each test.
path <- testthat_example("success") test_file(path, reporter = "minimal") # 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") str(out[[1]])