I know that testthat::expect_silent
will mark an expectation and test as a failure when there's a warning. Does anyone know if there's a way to mark a testing run for an entire package to fail if there are any warnings? I have a package for which I'd like to verify that none of the tests raise warnings, and I can wrap each and every expectation in expect_silent
, but I was hoping to somehow make that a global option that would cause the package build process (e.g. as launched via R CMD build
) to fail on any raised condition.
1 Like
I wonder whether you could set warnings as errors (and reset the option to its default value) in a testthat helper file, and get the behavior you are looking for.
withr::local_options(list(warn = 2))
- More info on test hygiene in testthat docs.
- About testthat helper files on the R-hub blog.
This topic was automatically closed after 45 days. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.