assertError
Test Expected Errors and Warnings

Description

Functions to test that other functions give expected errors and warnings.

Usage

assertError(expr, classes = "error", verbose = FALSE)
assertWarning(expr, classes = "warning", verbose = FALSE)
assertCondition(expr, ..., .exprString, verbose = FALSE)

Arguments

expr An expression expected to give a warning, error, or other condition.
classes A character vector giving the expected classes of conditions generated by expr.
verbose A logical value which is currently ignored.
.exprString A character string representing the expression in the error message. By default it will be a shortened version of deparse(expr).
... Unrecognized arguments to assertCondition will be combined to form a vector of expected classes.
Value
If evaluating expr generates a condition inheriting from one of the expected classes, the the function will return, invisibly, a list of the conditions generated. If no condition is generated, these functions will generate an error.
Note
The assertionTest package, among others, gives ways to test that the errors or warnings have the expected text.
Examples
expectError(noSuchFunction(noSuchdata))
Package tools version 6.1.4-13
Package Index