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

auto_test

Watches code and tests for changes, rerunning tests as appropriate.


Description

The idea behind auto_test() is that you just leave it running while you develop your code. Everytime you save a file it will be automatically tested and you can easily see if your changes have caused any test failures.

Usage

auto_test(
  code_path,
  test_path,
  reporter = default_reporter(),
  env = test_env(),
  hash = TRUE
)

Arguments

code_path

path to directory containing code

test_path

path to directory containing tests

reporter

test reporter to use

env

environment in which to execute test suite.

hash

Passed on to watch(). When FALSE, uses less accurate modification time stamps, but those are faster for large files.

Details

The current strategy for rerunning tests is as follows:

  • if any code has changed, then those files are reloaded and all tests rerun

  • otherwise, each new or modified test is run

In the future, auto_test() might implement one of the following more intelligent alternatives:

  • Use codetools to build up dependency tree and then rerun tests only when a dependency changes.

  • Mimic ruby's autotest and rerun only failing tests until they pass, and then rerun all tests.

See Also


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.