Skip to contents

Function operator to turn checkmate's check_*()-type functions into testthat's skip_if_not_*() functions.

Usage

make_skip_if_not_function(check.fun)

Arguments

check.fun

[function]
Function which checks the input. Must return TRUE on success and a string with the error message otherwise.

Details

Notice that check_*() are always formulated positively; the message from check_*() is emitted, when its condition is not met. The testthat equivalent is the opposite: a skip_if_not_*() function would skip with the emitted message.

You cannot generate skip_if_*() functions from check_*() functions, because the negation of the emitted message may be wrong or confusing. But you can create one manually:

skip_if_cond <- function(x) {
  testthat::skip_if(
    my_pkg::check_cond(x),
    # needs a custom message here
    "Skipping because condition is true."
  )
}

See also

Other testing helpers: transform_snap