expect_equal
, except that the
expected value is stored in an RDS file instead of being specified literally.
This can be helpful when the value is necessarily complex. If the file does
not exist then it will be created using the value of the specified object,
and subsequent tests will check for consistency against that generated value.
The test can be reset by deleting the RDS file.expect_equal_to_reference(object, file, ..., info = NULL, label = NULL,
expected.label = NULL)
expect_equal
label
for shortcut form.tests/testthat/
directory. Testing spawned
by devtools::test()
, for example, will accomplish this. But note that
testing spawned by R CMD check
and devtools::check()
will NOT.
In the latter cases, the package source is copied to an external location
before tests are run. The resulting RDS file will not make its way back into
the package source and will not be available for subsequent comparisons.equivalence
,
expect_equal
,
expect_equivalent
,
expect_identical
;
expect-compare
, expect_gt
,
expect_gte
, expect_less_than
,
expect_lt
, expect_lte
,
expect_more_than
;
expect_error
, expect_match
,
expect_message
,
expect_output
,
expect_warning
,
matching-expectations
;
expect_false
, expect_true
;
expect_is
; expect_named
;
expect_null
; expect_silent
;
takes_less_than
expect_equal_to_reference(1, "one.rds")
Run the code above in your browser using DataLab