
Last chance! 50% off unlimited learning
Sale ends in
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 to file.
Reporter to use to summarise output. Can be supplied
as a string (e.g. "summary") or as an R6 object
(e.g. SummaryReporter$new()
).
See Reporter for more details and a list of built-in reporters.
Environment in which to execute the tests. Expert use only.
Should the reporters start_reporter()
and
end_reporter()
methods be called? For expert use only.
Source helper files before running the tests?
See source_test_helpers()
for more details.
Deprecated. All files now assumed to be UTF-8.
Automatically wrap all code within test_that()
? This ensures
that all expectations are reported, even if outside a test block.
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.
# NOT RUN {
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]])
# }
Run the code above in your browser using DataLab