Check if testing infrastructure is present and refers to the current package, and if function files have a corresponding test file and vice versa.
Usage
check_tests(path = getwd(), pattern = "^test_|^test-", ignore_case = TRUE)Arguments
- path
character string containing a valid path to the package of which to check testing infrastructure and test files. The default is the working directory.
- pattern
character string containing a regular expression used to select test files.
- ignore_case
TRUEorFALSE: ignore case when matching filenames topattern?
Value
If all function files in folder R have a corresponding used test file and
vice versa (which also is the case if no test files and no function files are
present): character(0). Otherwise, a character vector with the names of
test files for which no function file is present and function files for which
no used test file is present.
Details
This function looks for R files starting with pattern pattern in folders
inst/tinytest and tests/testthat in the directory indicated by path,
which is where tinytest
and testthat place their
test files, respectively.
It is checked that testing infrastructure is present and refers to the current package, and that all test files have corresponding function files and vice versa. Test files are ignored if the corresponding test infrastructure is missing or wrong, with a warning. Function files of re-exported functions are ignored when looking for corresponding test files because these functions should be tested in the package from which they are re-exported.
Warnings are issued if:
none of the test directories exist
none of the test directories contain test files
test directories contain files that are ignored because their names do not start with pattern
pattern, are not R files, or are template files created bytinytestortestthattest directories used by
tinytestortestthatcontain test files while their test architecture is not set uptest directories contain test files without corresponding function files in folder
Rfolder
Rcontains function files without corresponding test filesfolder
Rcontains files that are not R filesfolder
Rdoes not contain any function filesfiles
<pkg>\tests\tinytest.Ror<pkg>\tests\testthat.Rdetermining which test infrastructure is used are present but do not refer to the current package, or the packagestinytestandtestthatare missing from the dependencies of the tested packagefile
<pkg>\tests\tinytest.Rnor<pkg>\tests\testthat.Ris presentfile
reexports.Rdis present in foldermanbut no re-exported functions are present in folderR
See also
Other functions to check tests:
diagnose_test_files(),
diagnose_test_infra()