teardown: Run code on setup/teardown

Description Usage Arguments Examples

View source: R/teardown.R

Description

Code in a setup() block is run immediately in a clean environment. Code in a teardown() block is run upon completion of a test file, even if it exits with an error. Multiple calls to teardown() will be executed in the order they were created.

Usage

1
2
3
teardown(code, env = parent.frame())

setup(code, env = parent.frame())

Arguments

code

Code to evaluate

env

Environment in which code will be evaluted. For expert use only.

Examples

1
2
3
4
5
6
7
8
## Not run: 

tmp <- tempfile()
setup(writeLines(tmp, "some test data"))
teardown(unlink(tmp))


## End(Not run)

Example output



testthat documentation built on March 2, 2020, 5:07 p.m.