8 Mysterious Warnings - Cannot display warnings while unit testing in RStudio

Good morning RStudio Community!

Today I am having a problem with RStudio and unit testing.

My team wants to have unit tests for all our code to ensure there are no bugs. Recently we discovered there are 8 mysterious warnings in our unit tests which do not produce error messages in the RConsole.

We cannot find where the warnings are coming from. What is the best way to show warnings that are hidden from testthat output when you do not know the location of the warning? We want get warnings to show up in the RConsole automatically after clicking the "Run Tests" button in RStudio. How can we display more than one warning at a time?

Here is what my team tried so far:

  1. We added the following code to expect silent output, but mysterious warnings still exist.
test_that("initialize without warnings", {
  expect_silent({
    # our code
  })
})
  1. We converted all warnings to fatal errors using R options, but we can only display the first warning.
options(
  warn = 2,
  error=recover
)
  1. We looked in the RConsole for warning messages, but there is zero output for warnings. There is only a number indicating that there are 8 warnings.
    image

After trying all three steps separately, we cannot figure out how to see warning messages created during a unit test. How can we see all the warning messages at the same time?

Hi there,

My first instinct when seeing the object 'testthat_print' not found error was that you might be working with an older version of testthat. After a little search I found this topic that indeed seems to link mysterious warnings to old versions:

Hope this helps,
PJ

What are these warnings? Where do you see them?

does

warnings()

show anything ?

This topic was automatically closed 21 days after the last reply. 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.