Learn R Programming

testthat (version 2.2.1)

teardown: Run code on setup/teardown

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

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

Run this code
# NOT RUN {
tmp <- tempfile()
setup(writeLines(tmp, "some test data"))
teardown(unlink(tmp))

# }

Run the code above in your browser using DataLab