I have tests for a package that check functions that may or may not return warnings, for example:
test_that("test", {
expect_true(is.na(log(NA)))
expect_true(is.na(log(-1)))
})
I am not interested in checking weather the warnings appeared. Is there a way how I could tell testthat
to ignore the warnings and not display them when running devtools::test()
?
I know I could pack each function in expect_warning
, or suppressWarnings
, but instead I'd like to do something like
test_that("test", {
ignoreAllTheWarningsInside({
expect_true(is.na(log(NA)))
expect_true(is.na(log(-1)))
})
})
Unfortunately options(warn = -1)
also does not seem to work for this.