I am using the excellent testthat package in R. My issue is that I cannot see any output from the message() function in the code being tested when using test_file. for example, say I have following code in a file called test_message.R
f <- function() {
message ("Message: Hello world")
cat ("Cat: Hello world\n")
return (1)
}
test_that ("message shows up", {
expect_equal(f(), 1)
})
I run test_file as follows and get the output below
> test_file("test_message.R")
Cat: Hello world
.
So I am not seeing the text from message().
However, when I run the code on its own I do see it:
> f()
Message: Hello world
Cat: Hello world
[1] 1
I know that by default, message() writes to stderr and cat writes to stdout and I'm guessing that test_file "intercepts" stderr to test for the text in warnings and errors. Is there any way I can configure things so I see message() text on the console?