This function is superseded in favour of expect_snapshot()
and friends.
This is a regression test that records interwoven code and output into a
file, in a similar way to knitting an .Rmd
file (but see caveats below).
verify_output()
is designed particularly for testing print methods and error
messages, where the primary goal is to ensure that the output is helpful to
a human. Obviously, you can't test that with code, so the best you can do is
make the results explicit by saving them to a text file. This makes the output
easy to verify in code reviews, and ensures that you don't change the output
by accident.
verify_output()
is designed to be used with git: to see what has changed
from the previous run, you'll need to use git diff
or similar.
Arguments
- path
Path to record results.
This should usually be a call to
test_path()
in order to ensure that the same path is used when run interactively (when the working directory is typically the project root), and when run as an automated test (when the working directory will betests/testthat
).- code
Code to execute. This will usually be a multiline expression contained within
{}
(similarly totest_that()
calls).- width
Width of console output
- crayon
Enable cli/crayon package colouring?
- unicode
Enable cli package UTF-8 symbols? If you set this to
TRUE
, callskip_if(!cli::is_utf8_output())
to disable the test on your CI platforms that don't support UTF-8 (e.g. Windows).- env
The environment to evaluate
code
in.