Testthat setup files

Setup files are good for global test setup that is tailored for test execution in non-interactive or remote environments, like turning off messaging and writing to the clipboard.

  • Setup files are not executed by devtools::load_all().
  • Setup files often contain the corresponding teardown code.
.                              
├── ...
└── tests
    ├── testthat
    │   ├── helper.R
    │   ├── setup.R
    │   ├── test-foofy.R
    │   └── (more test files)
    └── testthat.R
op <- options(reprex.clipboard = FALSE, reprex.html_preview = FALSE)

withr::defer(options(op), teardown_env())