Skip to content
Prev 7681 / 12125 Next

[R-pkg-devel] Is using global assignment in package tests allowed?

On 27/01/2022 11:18 a.m., Ben Bolker wrote:
Yes, tests should be able to create variables, but they shouldn't go 
overboard.  A test like

    x <- 1
    stopifnot(x == 1)

will wipe out x, but that's probably not such a big deal.  On the other 
hand, a test like

    c <<- function(...) stop('do not do this!')
    testthat::expect_error(c(1))

is probably not a good idea.

Duncan Murdoch