run_test_file {tinytest} | R Documentation |
Run an R file containing tests; gather results
run_test_file(file, at_home = TRUE, verbose = getOption("tt.verbose", TRUE), color = getOption("tt.pr.color", TRUE), remove_side_effects = TRUE)
file |
|
at_home |
|
verbose |
|
color |
|
remove_side_effects |
|
In tinytest, a test file is just an R script where some or all
of the statements express an expectation
.
run_test_file
runs the file while gathering results of the
expectations in a tinytests
object.
A list
of class tinytests
, which is a list
of tinytest
objects.
All calls to Sys.setenv
and options
defined in a test file are captured and undone once the test file has run.
Not all terminals support ansi escape characters, so colorized output can be
switched off. This can also be done globally by setting options(tt.pr.color=FALSE)
.
Some terminals that do support ansi escape characters may contain
bugs. An example is the RStudio terminal (RStudio 1.1) running on Ubuntu 16.04
(and possibly other OSs).
Other test-files: build_install_test
,
run_test_dir
,
summary.tinytests
,
test_package
# create a test file, in temp directory tests <- " addOne <- function(x) x + 2 expect_true(addOne(0) > 0) expect_equal(2, addOne(1)) " testfile <- tempfile(pattern="test_", fileext=".R") write(tests, testfile) # run test file out <- run_test_file(testfile,color=FALSE) out # print everything in short format, include passes in print. print(out, nlong=0, passes=TRUE)