Check the following example:
library(testthat)
expect_warning(tryCatch(stop("Error!"), error = function(e) warning(e)))
## Error: tryCatch(stop("Error!"), error = function(e) warning(e)) showed 0 warnings
## In addition: Warning message:
## In doTryCatch(return(expr), name, parentenv, handler) : Error!
Why does testthat say that there was no warnings?
Using the withWarnings
function discussed in here also shows no sign of warnings. Why tryCatch
does not produce warnings if it was asked for it?