Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

expectation

Construct an expectation object


Description

For advanced use only. If you are creating your own expectation, you should call expect() instead. See vignette("custom-expectation") for more details.

Usage

expectation(type, message, srcref = NULL, trace = NULL)

new_expectation(
  type,
  message,
  ...,
  srcref = NULL,
  trace = NULL,
  .subclass = NULL
)

exp_signal(exp)

is.expectation(x)

Arguments

type

Expectation type. Must be one of "success", "failure", "error", "skip", "warning".

message

Message describing test failure

srcref

Optional srcref giving location of test.

trace

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

...

Additional attributes for the expectation object.

.subclass

An optional subclass for the expectation object.

exp

An expectation object, as created by new_expectation().

x

object to test for class membership

Details

Create an expectation with expectation() or new_expectation() and signal it with exp_signal().


testthat

Unit Testing for R

v3.0.2
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre], RStudio [cph, fnd], R Core team [ctb] (Implementation of utils::recover())
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.