EVOLUTION-MANAGER
Edit File: test_file.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 all tests in a single file</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_file {testthat}"><tr><td>test_file {testthat}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Run all tests in a single file</h2> <h3>Description</h3> <p>Helper, setup, and teardown files located in the same directory as the test will also be run. </p> <h3>Usage</h3> <pre> test_file(path, reporter = default_compact_reporter(), package = NULL, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>path</code></td> <td> <p>Path to file.</p> </td></tr> <tr valign="top"><td><code>reporter</code></td> <td> <p>Reporter to use to summarise output. Can be supplied as a string (e.g. "summary") or as an R6 object (e.g. <code>SummaryReporter$new()</code>). </p> <p>See <a href="Reporter.html">Reporter</a> for more details and a list of built-in reporters.</p> </td></tr> <tr valign="top"><td><code>package</code></td> <td> <p>If these tests belong to a package, the name of the package.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional parameters passed on to <code>test_dir()</code></p> </td></tr> </table> <h3>Value</h3> <p>A list (invisibly) containing data about the test results. </p> <h3>Special files</h3> <p>Certain <code>.R</code> files have special significance in testthat: </p> <ul> <li><p> Test files start with <code>test</code> and are executed in alphabetical order. </p> </li> <li><p> Setup files start with <code>setup</code> and are executed before tests. If clean up is needed after all tests have been run, you can use <code>withr::defer(clean_up(), teardown_env())</code>. See <code>vignette("test-fixtures")</code> for more details. </p> </li> <li><p> Helper files start with <code>helper</code> and are executed before tests are run and, unlike setup files, are also loaded by <code>devtools::load_all()</code>. Helper files can be necessary for side-effect-y code that you need to run when developing the package interactively. It's certainly possible to define custom test utilities in a helper file, but they can usually be defined below <code style="white-space: pre;">R/</code>, just like any other internal function. </p> </li></ul> <p>There is another type of special file that we no longer recommend using: </p> <ul> <li><p> Teardown files start with <code>teardown</code> and are executed after the tests are run. Now we recommend interleaving setup and cleanup code in <code style="white-space: pre;">setup-</code> files, making it easier to check that you automatically clean up every mess that you make. </p> </li></ul> <p>All other files are ignored by testthat. </p> <h3>Environments</h3> <p>Each test is run in a clean environment to keep tests as isolated as possible. For package tests, that environment that inherits from the package's namespace environment, so that tests can access internal functions and objects. </p> <h3>Examples</h3> <pre> path <- testthat_example("success") test_file(path) test_file(path, reporter = "minimal") </pre> <hr /><div style="text-align: center;">[Package <em>testthat</em> version 3.1.5 <a href="00Index.html">Index</a>]</div> </body></html>