R/capture-condition.R
capture_condition.RdThese functions allow you to capture the side-effects of a function call
including printed output, messages and warnings. They are used to evaluate
code for expect_output(), expect_message(),
expect_warning(), and expect_silent().
capture_condition(code, entrace = FALSE) capture_error(code, entrace = FALSE) capture_expectation(code, entrace = FALSE) capture_message(code, entrace = FALSE) capture_warning(code, entrace = FALSE) capture_messages(code) capture_warnings(code)
| code | Code to evaluate |
|---|---|
| entrace | Whether to add a backtrace to the captured condition. |
Singular functions (capture_condition, capture_expectation etc)
return a condition object. capture_messages() and capture_warnings
return a character vector of message text.
#> <simpleMessage in message("First"): First #> >capture_messages(f())#> Warning: Second#> [1] "First\n" "Third\n"capture_warning(f())#>#> <simpleWarning in f(): Second>capture_warnings(f())#>#>#> [1] "Second"# Condition will capture anything capture_condition(f())#> <simpleMessage in message("First"): First #> >