summary.tinytests {tinytest}R Documentation

Tinytests object

Description

An object of class tinytests (note: plural) results from running multiple tests from script. E.g. by running run_test_file.

Usage

## S3 method for class 'tinytests'
summary(object, ...)

all_pass(x)

any_pass(x)

all_fail(x)

any_fail(x)

## S3 method for class 'tinytests'
x[i]

## S3 method for class 'tinytests'
print(
  x,
  passes = getOption("tt.pr.passes", FALSE),
  sidefx = getOption("tt.pr.sidefx", TRUE),
  limit = getOption("tt.pr.limit", 7),
  nlong = getOption("tt.pr.nlong", 3),
  ...
)

## S3 method for class 'tinytests'
as.data.frame(x, ...)

Arguments

object

a tinytests object

...

passed to format.tinytest

x

a tinytests object

i

an index

passes

[logical] Toggle: print passing tests?

sidefx

[logical] Toggle: print side effects?

limit

[numeric] Max number of results to print

nlong

[numeric] First nlong results are printed in long format.

Value

For summary a table object

For all_pass, any_pass, all_fail, any_fail: a single logical

For `[.tinytests` a tinytests object.

For as.data.frame. a data frame.

Details

By default, the first 3 failing test results are printed in long form, the next 7 failing test results are printed in short form and all other failing tests are not printed. These defaults can be changed by passing options to print.tinytest, or by setting one or more of the following global options:

For example, set options(tt.pr.limit=Inf) to print all test results. Furthermore, there is the option

which determines whether colored output is printed. If R is running in a dumb terminal (detected by comparing environment variable "TERM" to "dumb"), then this option is set to FALSE when the package is loaded.

See Also

Other test-files: build_install_test(), exit_file(), run_test_dir(), run_test_file(), test_package()

Examples

# create a test file in tempdir
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)

# extract testdir
testdir <- dirname(testfile)
# run all files starting with 'test' in testdir
out <- run_test_dir(testdir)
#
# print results
print(out)
summary(out)
dat <- as.data.frame(out)
out[1]


[Package tinytest version 1.4.1 Index]