Run the selected test_case_plan() cases using their generated files and
each suite's testthat helpers, setup and teardown. Each case starts in a
fresh R session and package copy. The package source and test code run
with your permissions, so use this with packages you trust.
The selected body is instrumented in the copy to observe completion.
Use a full suite run to exercise custom runners or dependencies on
other cases in the same session.
Usage
run_test_plan(
path = ".",
ids = NULL,
download_fixtures = FALSE,
fixture_cache = NULL,
seed = NULL,
timeout = Inf
)Arguments
- path
Path to the source package root.
- ids
Exact case IDs to run.
NULLruns the entire named plan.- download_fixtures
Allow HTTPS downloads of declared fixtures when a verified copy is unavailable in the cache. Defaults to
FALSE.- fixture_cache
BiocFileCache directory.
NULLuses the package's user cache directory,tools::R_user_dir("biocroxytest", "cache").- seed
An optional integer seed used independently for each selected case. With
NULL, each case gets a seed in its own R process.- timeout
Maximum seconds for each isolated R process, including package loading and suite hooks. Defaults to
Inf. Copying files and preparing fixtures take place before this limit starts. After a timeout the plan continues with the remaining cases. It attempts to stop child processes and records any cleanup error with the timeout. The maximum finite limit is.Machine$integer.max / 1000seconds.
Value
A list with revision, a content fingerprint, cases, a data
frame containing the selected case IDs, suites, paths, statuses,
durations in seconds, diagnostics and counts of distinct warning messages
(NA when unavailable), and environments, the R
version, platform, operating system, locale and loaded package versions
observed at the end of execution, by case ID. The duration is elapsed
time for the case, or elapsed runner time when execution is interrupted.
fixtures contains the preflight fixture sources, expected and observed
checksums, availability and diagnostics, keyed by case ID. A case with
an unavailable required fixture is incomplete and does not start.
replay holds the seed, RNG kind and selected environment settings for
executed cases, keyed by case ID. Use write_test_replay()
to export a failure. revision_format identifies the manifest rules.
Details
Results are tied to a revision fingerprint of the copied paths and file
contents. The manifest includes package code, both test suites, local
fixtures and declared extra inputs. See check_generated_tests() and
vignette("named-cases") for the copy rules.
A case is completed when it reaches the end and records a passing
expectation without skips. A failed expectation or test error gives
failed. An explicit skip from the case body before any passes gives
skipped. An early return, nested or partial skip, stale generated
case, timed-out R process or interrupted suite setup or teardown gives
incomplete. Absent generated files and absent case results give
missing. The case file and its declared code must agree before it runs.
See also
check_test_plan() to require completed cases in CI.
Examples
pkg <- tempfile("test-plan-example-")
dir.create(pkg)
writeLines("Package: examplepkg", file.path(pkg, "DESCRIPTION"))
run_test_plan(pkg)
#> $revision
#> [1] "17d803eaa1b8d1dd59cc6465666c7c24"
#>
#> $cases
#> [1] id suite source path status duration detail warnings
#> <0 rows> (or 0-length row.names)
#>
#> $environments
#> list()
#>
#> $fixtures
#> list()
#>
#> $replay
#> list()
#>
#> $revision_format
#> [1] 2
#>
unlink(pkg, recursive = TRUE)
