mkirk mkirk - 6 months ago 48
R Question

stubs and mocks in R

I've spent lots of time with RSpec and some time with xunit style tests. I've gotten accustom to having mocks and stubbing at my disposal.

Is there anything like mocks or stubbing in R? What frameworks have them?

If not how do you isolate your tests?


It wasn't available until 4 years after you asked this question, but it looks like testthat does include a with_mock() function now:

Seems to fit the bill pretty well.