Learn R Programming

testthat (version 3.1.10)

test_file: Run all tests in a single file

Description

Helper, setup, and teardown files located in the same directory as the test will also be run. See vignette("special-files") for details.

Usage

test_file(path, reporter = default_compact_reporter(), package = NULL, ...)

Value

A list (invisibly) containing data about the test results.

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.

package

If these tests belong to a package, the name of the package.

...

Additional parameters passed on to test_dir()

Environments

Each test is run in a clean environment to keep tests as isolated as possible. For package tests, that environment that inherits from the package's namespace environment, so that tests can access internal functions and objects.

Examples

Run this code
path <- testthat_example("success")
test_file(path)
test_file(path, reporter = "minimal")

Run the code above in your browser using DataLab