Skip to content

Previously, we recommended using expect() when writing your own expectations. Now we instead recommend pass() and fail(). See vignette("custom-expectation") for details.

Usage

expect(
  ok,
  failure_message,
  info = NULL,
  srcref = NULL,
  trace = NULL,
  trace_env = caller_env()
)

Arguments

ok

TRUE or FALSE indicating if the expectation was successful.

failure_message

Message to show if the expectation failed.

info

Character vector continuing additional information. Included for backward compatibility only and new expectations should not use it.

srcref

Location of the failure. Should only needed to be explicitly supplied when you need to forward a srcref captured elsewhere.

trace

An optional backtrace created by rlang::trace_back(). When supplied, the expectation is displayed with the backtrace. Expert use only.

trace_env

If trace is not specified, this is used to generate an informative traceack for failures. You should only need to set this if you're calling fail() from a helper function; see vignette("custom-expectation") for details.

Value

An expectation object from either succeed() or fail(). with a continue_test restart.

See also