File: expect.Rd

package info (click to toggle)
r-cran-testthat 3.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,452 kB
  • sloc: cpp: 9,261; ansic: 37; sh: 14; makefile: 5
file content (59 lines) | stat: -rw-r--r-- 2,117 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/expectation.R
\name{expect}
\alias{expect}
\title{The building block of all \code{expect_} functions}
\usage{
expect(
  ok,
  failure_message,
  info = NULL,
  srcref = NULL,
  trace = NULL,
  trace_env = caller_env()
)
}
\arguments{
\item{ok}{\code{TRUE} or \code{FALSE} indicating if the expectation was successful.}

\item{failure_message}{Message to show if the expectation failed.}

\item{info}{Character vector continuing additional information. Included
for backward compatibility only and new expectations should not use it.}

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

\item{trace}{An optional backtrace created by \code{\link[rlang:trace_back]{rlang::trace_back()}}.
When supplied, the expectation is displayed with the backtrace.}

\item{trace_env}{If \code{is.null(trace)}, this is used to automatically
generate a traceback running from \code{test_code()}/\code{test_file()} to
\code{trace_env}. You'll generally only need to set this if you're wrapping
an expectation inside another function.}
}
\value{
An expectation object. Signals the expectation condition
with a \code{continue_test} restart.
}
\description{
Call \code{expect()} when writing your own expectations. See
\code{vignette("custom-expectation")} for details.
}
\details{
While \code{expect()} creates and signals an expectation in one go,
\code{exp_signal()} separately signals an expectation that you
have manually created with \code{\link[=new_expectation]{new_expectation()}}. Expectations are
signalled with the following protocol:
\itemize{
\item If the expectation is a failure or an error, it is signalled with
\code{\link[base:stop]{base::stop()}}. Otherwise, it is signalled with
\code{\link[base:conditions]{base::signalCondition()}}.
\item The \code{continue_test} restart is registered. When invoked, failing
expectations are ignored and normal control flow is resumed to
run the other tests.
}
}
\seealso{
\code{\link[=exp_signal]{exp_signal()}}
}