Capture output to console
Evaluates code
in a special context in which all output is captured,
similar to capture.output()
.
capture_output(code, print = FALSE, width = 80) capture_output_lines(code, print = FALSE, width = 80) testthat_print(x)
code |
Code to evaluate. |
print |
If |
width |
Number of characters per line of output. This does not
inherit from |
Results are printed using the testthat_print()
generic, which defaults
to print()
, giving you the ability to customise the printing of your
object in tests, if needed.
capture_output()
returns a single string. capture_output_lines()
returns a character vector with one entry for each line
capture_output({ cat("Hi!\n") cat("Bye\n") }) capture_output_lines({ cat("Hi!\n") cat("Bye\n") }) capture_output("Hi") capture_output("Hi", print = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.