View source: R/expect-no-condition.R
expect_no_error | R Documentation |
These expectations are the opposite of expect_error()
,
expect_warning()
, expect_message()
, and expect_condition()
. They
assert the absence of an error, warning, or message, respectively.
expect_no_error(object, ..., message = NULL, class = NULL)
expect_no_warning(object, ..., message = NULL, class = NULL)
expect_no_message(object, ..., message = NULL, class = NULL)
expect_no_condition(object, ..., message = NULL, class = NULL)
object |
Object to test. Supports limited unquoting to make it easier to generate readable failures within a function or for loop. See quasi_label for more details. |
... |
These dots are for future extensions and must be empty. |
message , class |
The default, 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
Note that you should only use |
expect_no_warning(1 + 1)
foo <- function(x) {
warning("This is a problem!")
}
# warning doesn't match so bubbles up:
expect_no_warning(foo(), message = "bananas")
# warning does match so causes a failure:
try(expect_no_warning(foo(), message = "problem"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.