EVOLUTION-MANAGER
Edit File: test_that.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Run a test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for test_that {testthat}"><tr><td>test_that {testthat}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Run a test</h2> <h3>Description</h3> <p>A test encapsulates a series of expectations about a small, self-contained unit of functionality. Each test contains one or more expectations, such as <code><a href="equality-expectations.html">expect_equal()</a></code> or <code><a href="expect_error.html">expect_error()</a></code>, and lives in a <code style="white-space: pre;">test/testhat/test*</code> file, often together with other tests that relate to the same function or set of functions. </p> <p>Each test has its own execution environment, so an object created in a test also dies with the test. Note that this cleanup does not happen automatically for other aspects of global state, such as session options or filesystem changes. Avoid changing global state, when possible, and reverse any changes that you do make. </p> <h3>Usage</h3> <pre> test_that(desc, code) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>desc</code></td> <td> <p>Test name. Names should be brief, but evocative. It's common to write the description so that it reads like a natural sentence, e.g. <code>test_that("multiplication works", { ... })</code>.</p> </td></tr> <tr valign="top"><td><code>code</code></td> <td> <p>Test code containing expectations. Braces (<code>{}</code>) should always be used in order to get accurate location data for test failures.</p> </td></tr> </table> <h3>Value</h3> <p>When run interactively, returns <code>invisible(TRUE)</code> if all tests pass, otherwise throws an error. </p> <h3>Examples</h3> <pre> 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) }) ## Not run: test_that("trigonometric functions match identities", { expect_equal(sin(pi / 4), 1) }) ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>testthat</em> version 3.1.5 <a href="00Index.html">Index</a>]</div> </body></html>