File: test_that.Rd

package info (click to toggle)
r-cran-testthat 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,996 kB
  • sloc: cpp: 9,265; ansic: 37; sh: 15; makefile: 5
file content (40 lines) | stat: -rw-r--r-- 1,157 bytes parent folder | download
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/test-that.R
\name{test_that}
\alias{test_that}
\title{Create a test.}
\usage{
test_that(desc, code)
}
\arguments{
\item{desc}{test name.  Names should be kept as brief as possible, as they
are often used as line prefixes.}

\item{code}{test code containing expectations.  Braces (\code{{}}) should always be
used in order to get accurate location data for test failures.}
}
\description{
A test encapsulates a series of expectations about small, self-contained
set of functionality. Each test is contained in a \link{context} and
contains multiple expectations.
}
\details{
Tests are evaluated in their own environments, and should not affect
global state.

When run from the command line, tests return \code{NULL} if all
expectations are met, otherwise it raises an error.
}
\examples{
test_that("trigonometric functions match identities", {
  expect_equal(sin(pi / 4), 1 / sqrt(2))
  expect_equal(cos(pi / 4), 1 / sqrt(2))
  expect_equal(tan(pi / 4), 1)
})
# Failing test:
\dontrun{
test_that("trigonometric functions match identities", {
  expect_equal(sin(pi / 4), 1)
})
}
}