View source: R/unittest_methods.R
| check_pkg_tests_and_snaps | R Documentation |
This function inspects an R package source tree and detects the presence of common testing frameworks ('testthat', 'testit', base R tests, BioGenerics/Bioconductor-style tests) as well as snapshot files used for golden testing.
check_pkg_tests_and_snaps(pkg_source_path)
pkg_source_path |
Character. Path to the root of the package source. |
A list containing logical indicators and file counts describing the test configuration of the package. The list includes:
Logical. Whether 'tests/testthat/' exists.
Logical. Whether 'tests/testit/' exists.
Logical. Whether base R test files exist in 'tests/'.
Logical. Whether BioGenerics-style tests exist in 'inst/tests/'.
Character. Path to BioGenerics unit test directory (if any).
Character. Path to BioGenerics 'run_unitTests.R' (if any).
Logical. Whether '_snaps/' exists inside 'tests/testthat/'.
Integer. Number of snapshot test files inside '_snaps/'.
Integer. Number of 'test-*.R' files in 'tests/testthat/'.
This function always returns a value. It does **not** perform side effects other than reading the package directory structure.
# Adjust CRAN repo (example only)
r <- getOption("repos")
r["CRAN"] <- "http://cran.us.r-project.org"
old <- options(repos = r)
# Example package contained in test.assessr
dp <- system.file(
"test-data",
"test.package.0001_0.1.0.tar.gz",
package = "test.assessr"
)
# Set up package
install_list <- set_up_pkg(dp)
pkg_source_path <- install_list$pkg_source_path
# Install package locally (ensures correct test paths)
install_package_local(pkg_source_path)
# Detect tests and snapshots
test_pkg_data <- check_pkg_tests_and_snaps(pkg_source_path)
# Restore options
options(old)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.