I want to test a function that can throw an error but I also want to ensure that a variable value is correct (to verify the expected last state before the error - so I want to test for unwanted side effects). Is it possible to do this?
Simplified expression to be tested
x <- 1 # could also be made "global" by "<<-"
stop("damn, an error occured")
How can I do something like
testthat("double check",
expect_error_and_TRUE( x == 1, {
x <- 1
stop("damn, an error occured")
}))
I could not find a way to "stack" (pipe) the expect
functions?