Capture output to consoleSource:
code in a special context in which all output is captured,
capture_output(code, print = FALSE, width = 80) capture_output_lines(code, print = FALSE, width = 80) testthat_print(x)
Code to evaluate.
TRUEand the result of evaluating
codeis visible, print the result using
Number of characters per line of output. This does not inherit from
getOption("width")so that tests always use the same output width, minimising spurious differences.
capture_output() returns a single string.
capture_output_lines()returns a character vector with one entry for each line
Results are printed using the
testthat_print() generic, which defaults
print(), giving you the ability to customise the printing of your
object in tests, if needed.