Learn R Programming

testextra (version 0.1.0.1)

extract_tests: Extract tests from source

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

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

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

Examples

Run this code
# NOT RUN {
# Extract all files
extract_tests('.')

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

Run the code above in your browser using DataLab