Learn R Programming

testthat (version 2.2.1)

test_file: Run all tests in specified file

Description

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.

Usage

test_file(path, reporter = default_reporter(), env = test_env(),
  start_end_reporter = TRUE, load_helpers = TRUE,
  encoding = "unknown", wrap = TRUE)

Arguments

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. SummaryReporter$new()).

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 start_reporter() and end_reporter() methods be called? For expert use only.

load_helpers

Source helper files before running the tests? See source_test_helpers() for more details.

encoding

Deprecated. All files now assumed to be UTF-8.

wrap

Automatically wrap all code within test_that()? This ensures that all expectations are reported, even if outside a test block.

Value

Invisibily, a list with one element for each test.

Examples

Run this code
# 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