| mock_output_sequence {testthat} | R Documentation |
Mock a sequence of output from a function
Description
Specify multiple return values for mocking
Usage
mock_output_sequence(..., recycle = FALSE)
Arguments
... |
< |
recycle |
whether to recycle. If |
Value
A function that you can use within local_mocked_bindings() and
with_mocked_bindings()
See Also
Other mocking:
local_mocked_bindings()
Examples
# inside local_mocked_bindings()
## Not run:
local_mocked_bindings(readline = mock_output_sequence("3", "This is a note", "n"))
## End(Not run)
# for understanding
mocked_sequence <- mock_output_sequence("3", "This is a note", "n")
mocked_sequence()
mocked_sequence()
mocked_sequence()
try(mocked_sequence())
recycled_mocked_sequence <- mock_output_sequence(
"3", "This is a note", "n",
recycle = TRUE
)
recycled_mocked_sequence()
recycled_mocked_sequence()
recycled_mocked_sequence()
recycled_mocked_sequence()
[Package testthat version 3.3.2 Index]