File: tinytests.Rd

package info (click to toggle)
r-cran-tinytest 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,072 kB
  • sloc: sh: 14; makefile: 2
file content (126 lines) | stat: -rw-r--r-- 3,159 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/methods.R
\name{summary.tinytests}
\alias{summary.tinytests}
\alias{all_pass}
\alias{any_pass}
\alias{all_fail}
\alias{any_fail}
\alias{[.tinytests}
\alias{tinytests}
\alias{print.tinytests}
\alias{as.data.frame.tinytests}
\title{Tinytests object}
\usage{
\method{summary}{tinytests}(object, ...)

all_pass(x)

any_pass(x)

all_fail(x)

any_fail(x)

\method{[}{tinytests}(x, i)

\method{print}{tinytests}(
  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),
  ...
)

\method{as.data.frame}{tinytests}(x, ...)
}
\arguments{
\item{object}{a \code{tinytests} object}

\item{...}{passed to \code{\link{format.tinytest}}}

\item{x}{a \code{tinytests} object}

\item{i}{an index}

\item{passes}{\code{[logical]} Toggle: print passing tests?}

\item{sidefx}{\code{[logical]} Toggle: print side effects?}

\item{limit}{\code{[numeric]} Max number of results to print}

\item{nlong}{\code{[numeric]} First \code{nlong} results are printed in long format.}
}
\value{
For \code{summary} a \code{\link{table}} object

For \code{all_pass}, \code{any_pass}, \code{all_fail}, \code{any_fail}: 
 a single \code{logical}

For \code{`[.tinytests`} a \code{tinytests} object.

For \code{as.data.frame.} a data frame.
}
\description{
An object of class \code{tinytests} (note: plural) results
from running multiple tests from script. E.g. by running
\code{\link{run_test_file}}.
}
\section{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  \code{print.tinytest}, or by setting one or more of the following global
options:
\itemize{
\item{\code{tt.pr.passes} Set to \code{TRUE} to print output of non-failing tests.}
\item{\code{tt.pr.limit} Max number of results to print (e.g. \code{Inf})}
\item{\code{tt.pr.nlong} The number of results to print in long format (e.g. \code{Inf}).}
}

For example, set \code{options(tt.pr.limit=Inf)} to print all test results.
Furthermore, there is the option
\itemize{
\item{\code{tt.pr.color},}
}
which determines whether colored output is printed.
If R is running in a dumb terminal (detected by comparing 
environment variable \code{"TERM"} to \code{"dumb"}), then
this option is set to \code{FALSE} when the package is loaded.
}

\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]

}
\seealso{
Other test-files: 
\code{\link{build_install_test}()},
\code{\link{exit_file}()},
\code{\link{run_test_dir}()},
\code{\link{run_test_file}()},
\code{\link{test_package}()}
}
\concept{test-files}