It just took me a while to figure out the best way to test that a particular warning or error was thrown, so that means we need an example in the docs. (Same for other *what docs.)
I think that the best way is to use check_output(), including a Warning message: or Error: prefix.
Solution
warning("this is a warning")
stop("this is an error")
SCTs
ex() %>% check_output("Warning message: this is a warning", fixed = TRUE)
ex() %>% check_output("Error: this is an error", fixed = TRUE)
If you can distinguish output that went to stderr() rather than stdout(), you could maybe add an argument to check_output() to filter for just warnings and errors, but that may be overkill.
It just took me a while to figure out the best way to test that a particular warning or error was thrown, so that means we need an example in the docs. (Same for other *what docs.)
I think that the best way is to use
check_output()
, including aWarning message:
orError:
prefix.Solution
SCTs
If you can distinguish output that went to
stderr()
rather thanstdout()
, you could maybe add an argument tocheck_output()
to filter for just warnings and errors, but that may be overkill.