The default, message = NULL, class = NULL
,
will fail if there is any error/warning/message/condition.
In many cases, particularly when testing warnings and messages, you will
want to be more specific about the condition you are hoping not to see,
i.e. the condition that motivated you to write the test. Similar to
expect_error()
and friends, you can specify the message
(a regular
expression that the message of the condition must match) and/or the
class
(a class the condition must inherit from). This ensures that
the message/warnings you don't want never recur, while allowing new
messages/warnings to bubble up for you to deal with.
Note that you should only use message
with errors/warnings/messages
that you generate, or that base R generates (which tend to be stable).
Avoid tests that rely on the specific text generated by another package
since this can easily change. If you do need to test text generated by
another package, either protect the test with skip_on_cran()
or
use expect_snapshot()
.