extract_tests: Extract tests from source

Description Usage Arguments Details Examples

Description

Use this function to extract tests from package source files. In-source testing blocks are contained in blocks that are prevented from running when sourced by an if(FALSE){...} statement. It also contains a documentation tag to denote a testing block.

Usage

1
2
3
extract_tests(pkg = ".", filter = NULL,
  verbose = getOption("verbose", FALSE), full.path = NA,
  force = FALSE)

Arguments

pkg

The root directory of the package.

filter

If specified, only tests from files matching this regular expression are extracted.

verbose

Print message?

full.path

Include full file paths in generated files. TRUE, indicates full path, FALSE, indicated only basename, and NA(default) implies path relative to pkg.

force

Force test extraction even if the generated test file is newer than the corresponding source file.

Details

The first line of the block should look similar to

1
2
3
    if(FALSE){#@testing [optional information]
    ...
    }

Examples

1
2
3
4
5
6
7
8
## Not run: 
# Extract all files
extract_tests('.')

# Extract only files that start with 'Class-' or 'class-'
extract_tests('.', filter="^[Cc]lass-.*\\.[Rr]$")

## End(Not run)

testextra documentation built on Dec. 18, 2019, 9:38 a.m.