dimanche 13 novembre 2016

testthat: Expect error and variable value at once?

I want to test a function that can throw an error but I also want to ensure that a variable value is correct. Is it possible to do this?

Simplified expression to be tested

x <- 1
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?

Aucun commentaire:

Enregistrer un commentaire