- selection
String of code. (Character)
E.g. "stop('This gives an expect_error test')"
.
- indentation
Indentation of the selection. (Numeric)
- tolerance
The tolerance for numeric tests as a string, like "1e-4"
. (Character)
- round_to_tolerance
Whether to round numeric elements to the specified tolerance. (Logical)
This is currently applied to numeric columns and vectors (excluding some lists).
- strip
Whether to insert
strip_msg()
and
strip()
in tests of side effects. (Logical)
Sometimes testthat tests have differences in punctuation and newlines on different
systems. By stripping both the error message and the expected message of non-alphanumeric symbols,
we can avoid such failed tests.
- sample_n
The number of elements/rows to sample. Set to NULL
to avoid sampling.
Inserts smpl()
in the generated tests when sampling was used. A seed is
set internally, setting sample.kind
as "Rounding"
to ensure compatibility with R
versions
< 3.6.0
.
The order of the elements/rows is kept intact. No replacement is used, why no oversampling will
take place.
When testing a big data.frame
, sampling the rows can help keep the test files somewhat readable.
- envir
Environment to evaluate in. Defaults to
parent.frame()
.
- copy_env
Whether to work in a deep copy of the environment. (Logical)
Side effects will be captured in copies of the copy, why two copies of the environment will
exist at the same time.
Disabled by default to save memory but is often preferable to enable,
e.g. when the function changes non-local variables.
- assign_output
Whether to assign the output of a function call or long selection
to a variable. This will avoid recalling the function and decrease cluttering. (Logical)
Heuristic: when the `selection`
isn't of a string and contains a parenthesis, it is considered a function call.
A selection with more than 30 characters will be assigned as well.
The tests themselves can be more difficult to interpret, as you will
have to look at the assignment to see the object that is being tested.
- seed
seed
to set. (Whole number)
- test_id
Number to append to assignment names. (Whole number)
For instance used to create the "output_"
name: output_<test_id>
.
- add_wrapper_comments
Whether to add intro and outro comments. (Logical)
- add_test_comments
Whether to add comments for each test. (Logical)
- start_with_newline, end_with_newline
Whether to have a newline in the beginning/end. (Logical)
- out
Either "insert"
or "return"
.
"return"
Returns the expectations in a list
.
These can be prepared for insertion with
prepare_insertion()
.